[IronPython] ScriptRuntime.ImportModule("foo") vs. import foo

Slide slide.o.mix at gmail.com
Fri Oct 29 00:55:32 CEST 2010


I have something like the following code:

ScriptEngine engine = Python.CreateEngine();
ScriptScope scope = engine.CreateScope();

engine.Runtime.LoadAssembly(Assembly.GetExecutingAssembly()); // holds
the namespace foo

// the following line throws an exception
engine.Runtime.ImportModule("foo");

// the following if executed works fine
engine.Execute("import foo");


I'm basically just trying to make the types in my executing assembly
available to the script. I assumed that the ImportModule would see
things that had been loaded using LoadAssembly, but this doesn't seem
to be the case.

Does anyone have examples of doing this that works?

Thanks,

slide



More information about the Ironpython-users mailing list