SecurityException from Activator.CreateInstance(), How to grant permissons to Assembly?

Posted by user365164 on Stack Overflow See other posts from Stack Overflow or by user365164
Published on 2010-06-12T09:38:16Z Indexed on 2010/06/12 9:42 UTC
Read the original article Hit count: 309

Filed under:
|
|
|
|

I have been loading an assembly via Assembly.LoadFrom(@"path"); and then doing

Type t = asm.GetType("Test.Test");

test = Activator.CreateInstance(t, new Object[] { ... });

and it was working fine, but now I moved the dll I am getting the following

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Security.SecurityException: Request for the permission of type 'System.Security.Permissons.SecurityPermission, etc ..

For the sake of brevity it seems the demand was for an PermissionSet that allowed ControlAppDomain and it's not getting it.

My question is how can I create this permissionset and pass it to the instance or assembly? I've been googling for hours to no avail.

© Stack Overflow or respective owner

Related posts about c#

Related posts about dll