[IronPython] Running IronPython code from C#

Ryan Davis ryan at acceleration.net
Wed Jul 12 16:18:31 CEST 2006


You can keep your IP code in their own files, and then read those files 
into strings with C#, which makes it not quite as ugly.  Still not as 
nice as being able to reference a dll, but not so bad as embedding in C#.

Ryan Davis
Acceleration.net
Director of Programming Services
2831 NW 41st street, suite B
Gainesville, FL 32606

Office: 352-335-6500 x 124
Fax: 352-335-6506



Frédéric Cadier wrote:
> Thanks Eyvind,
>
> but this forces me to transfer my IP code in some C# strings ! What i
> want is being able to use the assembly generated from my ip scripts
> (using the language service of the VS20005 SDK) and then use it in my C#
> code...
>
> Eyvind Axelsen a écrit :
>   
>> 1 Add a reference to IronPython.dll in your project
>>
>> 2 Instantiate the python engine:
>>
>> IronPython.Hosting.PythonEngine pe = new IronPython.Hosting.PythonEngine();
>>
>> 3 Run your code: 
>>
>> string myCode = "some python code here";
>> pe.Execute(myCode);
>>
>> HTH,
>>
>> Eyvind.
>>
>> -----Opprinnelig melding-----
>> Fra: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] På vegne av Frédéric Cadier
>> Sendt: 12. juli 2006 11:03
>> Til: users at lists.ironpython.com
>> Emne: [IronPython] Running IronPython code from C#
>>
>> Hi everyone,
>>
>> I hope I won't be too annoying with a newbie question... but I'm
>> wondering how to run IP code from C# : I would for example define a
>> class MyClass in myclass.py, and want to instanciate it from some C# code.
>>
>> Can someone help me ?
>>
>> Thank you,
>> Frédéric Cadier
>> _______________________________________________
>> users mailing list
>> users at lists.ironpython.com
>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>> _______________________________________________
>> users mailing list
>> users at lists.ironpython.com
>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>>
>>
>>
>>   
>>     
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20060712/a3d62163/attachment.html>


More information about the Ironpython-users mailing list