[IronPython] Embedding IronPython and calling python functions from C#
Patrick van der Willik
patrick at toolmaker.nl
Thu Jun 11 07:32:24 PDT 2009
I'm currently attempting to embed the IronPython 2 runtimes into an
existing application written in C#. However, I find the amount of
documentation lacking on what I'm trying to do. I currently have a
proof-of-concept version which uses Lua and LuaInterface, but the people
who have to write the scripts dislike Lua(Well, more hate it with a
passion) and would love to see this working with Python.
My host application is a networked application that must trigger certain
scripts functions on events generated by the connected clients. The idea
is that when my application starts, it will load the IronPython script
environment, launches an 'autoexec.py' which will load various other
scripts files and do some housekeeping. Once this all is completed, it
will start listening to incoming connections. However, in various
scenarios, the application has to trigger scripted functions when data
is received from a client. Which script function is called is different
per client and per event. I have events for connecting, logging on,
disconnecting and a set of data specific events after receiving data.
This highly depends on the received packets.
My question here is: How do I embed IronPython in such a fashion that I
can load my scripts and then trigger various functions within that? I've
seen many examples that just call CreateScriptSourceFromString() or File
each time in which just 1 piece of code is implemented. This is not
suitable for the needs here because the scripted systems can become
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Users