[IronPython] IronPython & Silverlight
Craig S. Perler 04
Craig.S.Perler.04 at Alum.Dartmouth.ORG
Tue Jan 22 16:38:29 PST 2008
You're correct, I'm trying to host IronPython in an
existing C# SL app and I would like to use the .NET
libraries from IronPython. I hadn't realized or noticed,
however, that the dlls shipped with SL are not the same as
those available for production use from IronPython
directly. My app references IronPython.dll version
188.8.131.52, runtime version 2.0.50727, file version
1.1.20625.0. Is there a more appropriate and still SL
compatible version to use?
That aside, the IronPython-relevant aspect of my app is
straightforward: grab a string from a textbox, pass it via
The C# method that handles this process is below. It
Python code. For the sake of debugging at first at least,
it then assumes that a function "func" was defined, as
that's then evaluated.
public void Execute(string script)
PythonEngine engine =
object result = engine.Evaluate("func()");
if (result != null)
catch (Exception e)
Prior to any execution as per above, I initialize PAL
exactly as described here:
Thoughts on what I'm doing wrong?
---Discussion of IronPython <users at lists.ironpython.com>
> Craig S. Perler wrote:
> I'm having problems accessing .NET libraries from
> IronPython hosted within a Silverlight application and
> have hit a wall. If you have any advice, I'd be most
The work around for hosting IronPython in Silverlight 1.1
is a little messy, since the DLR should take care of this
and not require the user's app to override the PAL. We are
revisiting this for the next release of Silverlight to
make it work well.
I assume you'd like to host IronPython in an existing C#
SL app? If you can do without C# code, and without the
bleeding edge IronPython version ... you could just use
the IronPython version shipped in Silverlight. There are
samples on silverlight.net if you'd like examples on how
to do it.
> To describe my setup... I'm first initializing the
> PlatformAdaptationLayer with the details described here
> ng_ironpython.shtml]. I'm not certain what exactly that
> does, but it seems clear that no amount of fiddling
> in IronPython works without detailing the
> ScriptEnvironmentSetup. With that in place, I see a bit
> progress: I can execute the script "def func():\r\n
> return 'in Func()'" and then retrieve the result by
> evaluating the script "func()".
> I've tried a variety of combinations to gain access to
> System.DateTime from the Python script, but they all end
> up with an error like the one below. Additionally, this
> error is also similar to the one I receive when
> to call PythonEngine.ExecuteFile(string path), which I
> have thus far been unable to get to work.
Can you send me the source or a smaller repro of the
issue? Michael, did you run into any of these issues?
Users mailing list
Users at lists.ironpython.com
--- End of quote ---
More information about the Users