Re: Reflection impossible unless FullTrust granted
From: Martin Daetz (m.daetz_at_deutschepost.de)
Date: 08/18/03
- Next message: vlad: "Security question"
- Previous message: IT Community [MSFT]: "RE: Bypassing form Authentication"
- In reply to: Ivan Medvedev [MS]: "Re: Reflection impossible unless FullTrust granted"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Mon, 18 Aug 2003 02:20:50 -0700
Thanks, now the picture is clear and bright!
Martin
>-----Original Message-----
>Martin -
>perhaps you are trying to instantiate a type that has a
declarative request
>for full trust (you can see declarative requests with
permview tool), or
>comes from a strongly named assembly that does not have
>AllowPartiallyTrustedCallersAttribute on it. If so, the
behavior you are
>observing is expected. You can fix this by removing the
declarative request
>or putting the attribute on the assembly respectively.
>--Ivan
>This posting is provided "AS IS" with no warranties, and
confers no rights.
>
>
>"Martin Daetz" <m.daetz@deutschepost.de> wrote in message
>news:0dce01c36333$c1c91a90$a101280a@phx.gbl...
>> Hello,
>> trying to instanciate an object of a class from another
>> class in onather assembly works fine as long the
>> FullTrust PermissionSet ist granted to the
instanciating
>> Assembly. Switching from FullTrust to Everything leads
to
>> a SecurityException: Request Failed...
>>
>> <Code>
>> <Class1Assembly>
>> namespace ReflPerm
>> {
>> public class NonSense
>> {
>> public NonSense()
>> {
>> }
>> private string Murkel = "purz";
>>
>> private string getMurkel()
>> {
>> return Murkel;
>> }
>> }
>> }
>> </Class1Assembly>
>> <InstanciatingAssembly>
>> try
>> {
>> FileStream stre = new FileStream(
>> @"..\..\..\bin\debug\ReflPerm.dll", FileMode.Open );
>> byte [] Array = new Byte[
stre.Length ];
>> stre.Read( Array, 0, ( int )
>> stre.Length );
>> Assembly Ass = Assembly.Load( Array );
>> Object obj = Ass.CreateInstance
>> ( "ReflPerm.NonSense", false,
>> BindingFlags.CreateInstance, null, new Object[] {},
null,
>> null );
>> Type t = Ass.GetType
>> ( "ReflPerm.NonSense" );
>> string str = ( string ) t.InvokeMember
>> ( "getMurkel", BindingFlags.InvokeMethod |
>> BindingFlags.NonPublic | BindingFlags.Instance, null,
>> obj, new object [] {} );
>> label1.Text = str;
>> }
>> catch ( Exception ex )
>> {
>> }
>> </InstanciatingAssembly>
>> </Code>
>>
>> In the callstack of the CreateInstance the exception is
>> thrown.
>>
>> thx Martin
>
>
>.
>
- Next message: vlad: "Security question"
- Previous message: IT Community [MSFT]: "RE: Bypassing form Authentication"
- In reply to: Ivan Medvedev [MS]: "Re: Reflection impossible unless FullTrust granted"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]