[IronPython] Calling a Python function (compiled into an assembly) from C# using delegates.

Renaud Durand neraun at gmail.com
Wed Jan 21 21:52:03 CET 2009

I have found something that works, thanks to you :-).

Given an IronPython assembly "mymodule.dll" with the function "myFunction"

  eng = Python.CreateEngine()

  ScriptScope scope = eng.CreateScope();

  cmd = "from mymodule  import myFunction"

  //Get the interpretMapping function
  Func<string, object> myFunction;
  interpretMapping = scope.GetVariable<Func<string, object>>("myFunction");
  ObjectOperations ops = eng.Operations;
  object bar = myFunction("foo");
  object method = ops.GetMember(item, "myMethod");

Thanks for your patience and your answers.

Renaud Durand
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20090121/ab92691b/attachment.html>

More information about the Ironpython-users mailing list