Application Domains
OS
|__Process
|___.NET Runtime
|__App Domain 1
|__Assembly 1
|__Assembly 2
|__App Domain 2
|__Assembly 2
|__Assembly 3
|__App Domain 1
|__App Domain 2
Benefits
| Reliability | Does not crash the whole process or affect other app domains. |
| Efficiency | Can load large assembly into app domain and is removed from memory when app domain removed. |
AppDomain d = AppDomain.CreateDomain("NewDomain");
AppDomain.CurrentDomain.FriendlyName;
d.FriendlyName;
d.ExecuteAssembly("Assembly.exe");
d.ExecuteAssemblyByName("Assembly");
d.Load("Assembly.dll");
AppDomain.Unload(d);
object[] hostEvidence = { new Zone(SecurityZone.Internet) }
Evidence appEvidence = new Evidence(hostEvidence, null);
appEvidence.AddHost(new Zone(..));
AppDomainSetup ads = new AppDomainSetup();
ads.ApplicationBase
ads.DisallowBindingRedirects
ads.DisallowCodeDownload
d = AppDomain.CreateDomain("NewDomain", appEvidence, ads);