Do I do something fundamentally wrong here... The below is what I get do a
disasm on the SL5 assembly in the latest distribution (2.7.2.1)

Greatful for any help I could get in the right direction.

Best regards,

Mattias

2012/4/18 Mattias Ahlenius <matt...@goodsolutions.se>

>
> I get the following when I make a disam in Reflector, the exception
> (System.MethodAccessException) that I'm getting is not subclassing neither
> SecurityException or ArgumentException which is catched and handled.
>
>
>  *private static string 
> <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:5.0.5.0:7cec85d7bea7798e/System.String>
>  GetPrefix 
> <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://IronPython:2.7.1300.40:7f709c5b713576e1/IronPython.Modules.SysModule/GetPrefix():String>()
> {
>     try
>     {
>         return Path 
> <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:5.0.5.0:7cec85d7bea7798e/System.IO.Path>.GetDirectoryName
>  
> <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:5.0.5.0:7cec85d7bea7798e/System.IO.Path/GetDirectoryName(String):String>(Assembly
>  
> <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:5.0.5.0:7cec85d7bea7798e/System.Reflection.Assembly>.GetExecutingAssembly
>  
> <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:5.0.5.0:7cec85d7bea7798e/System.Reflection.Assembly/GetExecutingAssembly():System.Reflection.Assembly>().Location
>  
> <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:4.0.0.0:b77a5c561934e089/System.Reflection.Assembly/property:Location:String>);
>     }
>     catch (SecurityException 
> <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:5.0.5.0:7cec85d7bea7798e/System.Security.SecurityException>)
>     {
>         return string 
> <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:5.0.5.0:7cec85d7bea7798e/System.String>.Empty
>  
> <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:5.0.5.0:7cec85d7bea7798e/System.String/Empty>;
>     }
>     catch (ArgumentException 
> <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:5.0.5.0:7cec85d7bea7798e/System.ArgumentException>)
>     {
>         return string 
> <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:5.0.5.0:7cec85d7bea7798e/System.String>.Empty
>  
> <http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:5.0.5.0:7cec85d7bea7798e/System.String/Empty>;
>     }
> }*
>
> **/Mattias
> *
> *
>
> 2012/4/18 Slide <slide.o....@gmail.com>
>
>> This really sounds like the assemblies you are referencing are not really
>> the SL assemblies, can you open the assembly in ILSpy and decompile
>> GetPrefix and see what you have?
>>
>> slide
>>
>>
>> On Wed, Apr 18, 2012 at 1:44 PM, Mattias Ahlenius <
>> matt...@goodsolutions.se> wrote:
>>
>>> 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....@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
>>>> <matt...@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 <r...@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 | kr...@wintellect.com
>>>> >>
>>>> >> 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
>>>> >>
>>>> >>
>>>> >
>>>> >
>>>> >
>>>> >
>>>> > --
>>>> >
>>>> > Med vänlig hälsning,
>>>> >
>>>> > 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
>>>> >
>>>>
>>>>
>>>>
>>>> --
>>>> Website: http://earl-of-code.com
>>>>
>>>
>>>
>>>
>>> --
>>>
>>> Med vänlig hälsning,
>>>
>>> Mattias Ahlenius
>>> 031 - 788 19 25
>>>
>>> Good Solutions AB
>>> http://www.goodsolutions.se
>>>
>>>
>>
>>
>> --
>> Website: http://earl-of-code.com
>>
>
>
>
> --
>
> Med vänlig hälsning,
>
> 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@python.org
http://mail.python.org/mailman/listinfo/ironpython-users

Reply via email to