[IronPython] Loading DLL from pyc.py into ScriptEngine

hellosticky hellosticky at gmail.com
Tue Aug 26 23:51:44 CEST 2008


Hi,

I created an IronPython DLL with "ipy.exe pyc.py /out:test /target:dll test.py" which created test.dll. Now, from C#, I'd like to execute test.py from test.dll. I just opened up dlr-spec-hosting and there's a CreateScriptSourceFromStream, but I don't see that in 2.0 Beta 4 bits. Here is where I'm stuck. How do I get that assembly into the engine and then execute test.py? Also, I'd like to get the output into a string (I guess I can just redirect Console.Out?)

public string Execute(string assemblyName)
{
    string content = null;

    Assembly assembly = Assembly.Load(assemblyName);
    ScriptRuntime runtime = ScriptRuntime.Create();
    ObjectOperations operations = runtime.CreateOperations();
    ScriptEngine engine = runtime.GetEngine("py");
    // magic..

    return content;
}

Thanks,




More information about the Ironpython-users mailing list