[IronPython] Need help using IronPython from C#

Jason Ferrara jason.ferrara at jacquette.com
Fri Aug 11 21:07:45 CEST 2006


I'd like to do the equivalent of something like...

import RemoteAdmin

ls = RemoteAdmin.ConnectToService("localhost","LogViewer")
numEntries = ls.GetNumberOfEntries()
e = ls.GetEntry(numEntries - 1)
entryString = str(e)


in C#.

So I get as far as....

PythonEngine e = new PythonEngine();
# The RemoteAdmin module is in an assembly built using  
IronPython.Hosting.Compiler and then referenced by the C# project
ClrModule clr = (ClrModule) e.Import("clr");
clr.AddReference(typeof(RemoteAdmin).Assembly)
e.Import("RemoteAdmin");

and then I'm lost.

Is there a way to make a delegate from a method that exists in the  
PythonEngine environment and then call the delegate from C#?

I'm aware of the Evaluate and Execute methods of PythonEngine, but  
I'm looking for a more direct way to call the python methods and  
access python object attributes, rather than building up strings to  
pass to Evaluate.

Thanks

- Jason





More information about the Ironpython-users mailing list