[Ironpython-users] Problem with embedding IronPython into Silverlight Application

Mattias Ahlenius mattias at goodsolutions.se
Wed Apr 18 22:44:41 CEST 2012


Same exception even if I use the 2.7.2.1 bins: (I support you mean 2.7..
and not 2.5..)

Message: Failed to load language 'IronPython 2.7.2.1': The type initializer
for 'IronPython.Modules.SysModule' threw an exception.

InnerException:

"Attempt by security transparent method
'IronPython.Modules.SysModule.GetPrefix()' to access security critical
method 'System.Reflection.Assembly.get_Location()' failed."

/Mattias

2012/4/18 Slide <slide.o.mix at gmail.com>

> Please make sure you have 2.5.2.1 and not just 2.5.2.
>
> On Wed, Apr 18, 2012 at 12:16 PM, Mattias Ahlenius
> <mattias at goodsolutions.se> wrote:
> > Thanks for your quick reply Keith,
> >
> > Tried you code and I still get the same Exception:
> >
> > "Attempt by security transparent method
> > 'IronPython.Modules.SysModule.GetPrefix()' to access security critical
> > method 'System.Reflection.Assembly.get_Location()' failed."
> >
> > /Mattias
> >
> >
> >
> > 2012/4/18 Keith Rome <rome at wintellect.com>
> >>
> >> 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 | krome at wintellect.com
> >>
> >> www.wintellect.com
> >>
> >>
> >>
> >> From: ironpython-users-bounces+rome=wintellect.com at python.org
> >> [mailto:ironpython-users-bounces+rome=wintellect.com at python.org] On
> Behalf
> >> Of Mattias Ahlenius
> >> Sent: Wednesday, April 18, 2012 2:41 PM
> >> To: ironpython-users at 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
> >>
> >>
> >
> >
> >
> >
> > --
> >
> > Med vänlig hälsning,
> >
> > Mattias Ahlenius
> > 031 - 788 19 25
> >
> > Good Solutions AB
> > http://www.goodsolutions.se
> >
> >
> > _______________________________________________
> > Ironpython-users mailing list
> > Ironpython-users at python.org
> > http://mail.python.org/mailman/listinfo/ironpython-users
> >
>
>
>
> --
> Website: http://earl-of-code.com
>



-- 

Med vänlig hälsning,

Mattias Ahlenius
031 - 788 19 25

Good Solutions AB
http://www.goodsolutions.se
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20120418/4007752a/attachment.html>


More information about the Ironpython-users mailing list