IronPythonエンジンインスタンスへの参照を追加しようとすると、参照が期待通りに参照に追加されます。エンジンの別のインスタンスを作成すると、AddReferenceはエラーなしで実行されますが、参照は参照に追加されず、importステートメントは "no module named ..."で失敗します。2番目のIronPythonエンジンでclr.AddReferenceが失敗するのはなぜですか?
var engine = Python.CreateEngine();
dynamic clr = engine.Runtime.GetClrModule();
clr.AddReference("IronPython.StdLib");
var references = (IEnumerable<Assembly>)clr.References;
Debug.Assert(references.Any(asm => asm.FullName.StartsWith("IronPython.StdLib"))); // ok
var source = "import pydoc\npydoc.plain(pydoc.render_doc(str))";
var result = engine.Execute<string>(source);
Debug.Assert(result.StartsWith("Python Library Documentation")); // ok
var engine2 = Python.CreateEngine();
dynamic clr2 = engine2.Runtime.GetClrModule();
clr2.AddReference("IronPython.StdLib");
var references2 = (IEnumerable<Assembly>)clr.References;
Debug.Assert(references2.Any(asm => asm.FullName.StartsWith("IronPython.StdLib"))); // fails
result = engine.Execute<string>(source); // throws ImportException "no module named pydoc"
Debug.Assert(result.StartsWith("Python Library Documentation"));
Iは、(GACにインストールされている)とC#4.5、IronPython.StdLib
はPYCとPythonの標準IIbのプリコンパイルされたDLLであるIronPythonの2.7.5のバイナリリリースしようとしました。
また、githubからの自己コンパイル済みのIronPython 2.7.5および2.7.6でも試しましたが、最初にengine.execute
が参照が追加されていますが、で既に失敗しています。
私は何か間違っているのですか、それとも単なるバグですか?