[IronPython] Using IronPython as an assembly in dotNET

Lukas Dubeda loocas at duber.cz
Thu Aug 13 19:14:58 CEST 2009

Hi there everyone,

I have a problem I can't seem to figure out.

I want to use IronPython as an assembly via dotNET, I managed to load it 
as an assembly and access various constructors, classes etc...

However, I have a problem with executing Python code from the host 
application. I'm using 3ds Max to load up the assembly via dotNET. The 
code looks like this:

Assembly = dotNetClass "System.Reflection.Assembly" -- loading the 
assembly class
Assembly.LoadFrom "C:\IronPython-2.0.1\IronPython.dll" -- loading IronPython

ironPythonHosting = dotNetClass "IronPython.Hosting.Python" -- loading 
the hosting class
pythonEngine = ironPythonHosting.CreateEngine() -- creating an engine

Now, when I execute:


it runs smoothly and executes the tst.py and whatever Python code that's 

Now, I want to execute the code directly, not via a saved file. I tried 

pythonEngine.Execute("print 'TEST'")

but it throws me an error:

-- Error occurred in anonymous codeblock; filename: ; position: 344
-- Runtime error: dotNet runtime exception: Late bound operations cannot 
be performed on types or methods for which ContainsGenericParameters is 

Also, if I execute the Python code inside a file, is there a way to get 
the result/feedback from the code back to the host application? Via 
dotNET or IronPython? Or anyhow? So that I can write more complex tools 
that'd communicate with Pyhon code from within 3ds Max.

Thanks a lot in advance, cheers,

- Lukas Dubeda

More information about the Ironpython-users mailing list