Skip to content

Instantly share code, notes, and snippets.

@vendettamit
Created September 20, 2014 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vendettamit/1ea2be1d8c97f78c3933 to your computer and use it in GitHub Desktop.
Save vendettamit/1ea2be1d8c97f78c3933 to your computer and use it in GitHub Desktop.
Creating custom AppDomain
public class DomainController
{
public void CreateDomain()
{
string pathToDlls = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);
Trace.WriteLine(AppDomain.CurrentDomain.FriendlyName);
AppDomainSetup domainSetup = new AppDomainSetup { };
domainSetup.ApplicationBase = pathToDlls;
this.testDomain = AppDomain.CreateDomain(Guid.NewGuid().ToString(), null, domainSetup, this.GetPermissionSet());
}
private PermissionSet GetPermissionSet()
{
// create an evidence of type zone
var ev = new Evidence();
ev.AddHostEvidence(new Zone(SecurityZone.MyComputer));
// return the PermissionSets specific to the type of zone
return SecurityManager.GetStandardSandbox(ev);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment