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

Renaud Durand neraun at gmail.com
Wed Jan 21 17:11:50 CET 2009


That is the point. I don't want to do that from a file but from an Assembly
(dll).

2009/1/21 Dino Viehland <dinov at microsoft.com>

>  You need to do:
>
>
>
> eng.ExecuteFile('myfile.py', scope);
>
>
>
> *From:* users-bounces at lists.ironpython.com [mailto:
> users-bounces at lists.ironpython.com] *On Behalf Of *Renaud Durand
> *Sent:* Wednesday, January 21, 2009 7:45 AM
> *To:* dody at nomadlife.org; Discussion of IronPython
> *Subject:* Re: [IronPython] Calling a Python function (compiled into an
> assembly) from C# using delegates.
>
>
>
> Ok, but how ?
>
> 2009/1/21 Dody Gunawinata <empirebuilder at gmail.com>
>
> I think you have to import the function - loading the assembly alone is not
> enough.
>
> On Wed, Jan 21, 2009 at 5:17 PM, Renaud Durand <renaud.durand.it at gmail.com>
> wrote:
>
>  Hi again,
>
> I'm trying to call a python function from C#. I found out through a
> tutorial how to do it from
> a Python source file but I would like to do it from a compiled assembly.
> Some elements are missing.
> I think it is something like below but this does not work:
>
>             eng = Python.CreateEngine()
>             Assembly interpreter = Assembly.Load("interpreter");
>             eng.runtime.LoadAssembly(interpreter);
>
>             ScriptScope scope = eng.CreateScope();
>
>             //Get the interpretMapping function
>             Func<string, object> interpretMapping;
>             interpretMapping = scope.GetVariable<Func<string,
> object>>("interpretMapping");
>             ObjectOperations ops = eng.Operations;
>
>             //Get the interpItem returned by function.
>             object item =
> interpretMapping("649AC0165011B1E8F726AC54C911000000000000000000000000000000000000");
>             //Get the display Method
>             object method = ops.GetMember(item, "display");
>             ops.Call(method);
>
> Thank you... Again :-)
>
> --
> Renaud Durand
> EPITA Student
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
>
>
> --
> nomadlife.org
>
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
>
>
> --
> Renaud Durand
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>


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


More information about the Ironpython-users mailing list