Does this not work for you?

using IronPython.Hosting;
// ...
_python = Python.CreateEngine();

I believe that should handle the simple/typical scenarios, unless you need to 
alter the environment (such as plugging in a custom Host/PAL).

If you need to customize the environment, then this should work:

var options = new Dictionary<string, object>();
ScriptRuntimeSetup setup = Python.CreateRuntimeSetup(options);
_runtime = new ScriptRuntime(setup);
_python = Python.GetEngine(_runtime);


This code should work exactly the same on desktop CLR and Silverlight.



Keith Rome
Senior Consultant and Architect
MCPD-EAD, MCSD, MCDBA, MCTS-WPF, MCTS-TFS, MCTS-WSS
Wintellect | 770.617.4016 | kr...@wintellect.com<mailto:r...@wintellect.com>
www.wintellect.com<http://www.wintellect.com/>

From: ironpython-users-bounces+rome=wintellect....@python.org 
[mailto:ironpython-users-bounces+rome=wintellect....@python.org] On Behalf Of 
Mattias Ahlenius
Sent: Wednesday, April 18, 2012 2:41 PM
To: ironpython-users@python.org
Subject: [Ironpython-users] Problem with embedding IronPython into Silverlight 
Application

Hi,

I'm new to scripting and would like to add support for IronPython to our 
Silverlight application, I have tried to find an answer on the net but could 
not find anyone else facing the same problem. The app is an out of browser 
application.

I've added the latest release (2.7.2) from nuget, checked that the binaries 
being used is from the SL5 libs-catalog: IronPython.2.7.2\lib\Sl5

The code I use to create the scripting engine is the following:

..

            _runtime = new 
ScriptRuntime(DynamicEngine.CreateRuntimeSetup(true));

            _python = _runtime.GetEngine("py");
..

When GetEngine is executed I'll the following secutiry exception:

"{System.MethodAccessException: Attempt by security transparent method 
'IronPython.Modules.SysModule.GetPrefix()' to access security critical method 
'System.Reflection.Assembly.get_Location()' failed.
   at IronPython.Modules.SysModule.GetPrefix()
   at IronPython.Modules.SysModule..cctor()}"

When checking the code at GitHub for the method: GetPrefix()

There are code checking a compiler-constant that seems to be if you running in 
"silverlight" (don't have diskaccess to the libs), but the code seems to be 
executed anyway, which makes me wonder if I still doesn't use the correct libs 
for Silverlight.


Would really appreciate if someone could point me in the right direction.


Have a nice day!
--
Best regards,

Mattias Ahlenius
031 - 788 19 25

Good Solutions AB
http://www.goodsolutions.se

_______________________________________________
Ironpython-users mailing list
Ironpython-users@python.org
http://mail.python.org/mailman/listinfo/ironpython-users

Reply via email to