CAS is pretty much what you need here. More specifically, you want to load the assembly into your own application domain:
var myEvidence = new Evidence(new object[] {SecurityZone.Internet}); var newDomain = AppDomain.CreateDomain("InternetDomain"); myDomain.Load("MyUntrustedAssembly.dll", myEvidence); myDomain.CreateInstanceAndUnwrap("MyUntrustedAssembly","MyUntrustedObjectType");
Read about the application domains, different zones, and the default permission sets assigned to them. The Internet is the most restrictive for system zones / permission sets available for assembly, which can actually be performed (there is also a limited zone, assemblies falling into this zone cannot be executed). You can use the .NET Configuration tool to create permission sets and determine the conditions (evidence) that code must satisfy in order to provide a permission set.
source share