An application domain is an isolated environment in which Microsoft .NET assemblies can be sandboxed, granted specific permissions or PermissionSets and executed.
Definition:
An AppDomain represents an application domain in which compiled Microsoft .NET assemblies can be isolated from other assemblies (either in the root application or other, separate AppDomains). While AppDomains are typically used to sandbox third-party or otherwise untrusted code, they can also be used to separate code from the main process to prevent potential instability in a specific segment of an application.
Tag Usage:
The appdomain tag should be used when referencing issues related to the System.AppDomain
class in Microsoft .NET or related remoting or process issues.
Example (C#):
namespace AppDomainExample
{
using System;
using System.IO;
using System.Reflection;
using System.Security;
using System.Security.Permissions;
using System.Security.Policy;
class Program
{
static void Main(string[] args)
{
PermissionSet ps = new PermissionSet(PermissionState.None);
ps.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution));
ps.AddPermission(new FileIOPermission(FileIOPermissionAccess.Write, @"C:\"));
var assembly = Assembly.GetExecutingAssembly();
AppDomainSetup ads = new AppDomainSetup();
ads.ApplicationBase = Path.GetFullPath(assembly.Location);
StrongName fullTrustAssemblies = assembly.Evidence.GetHostEvidence<StrongName>();
AppDomain domain = AppDomain.CreateDomain("foo", null, ads, ps, fullTrustAssemblies);
}
}
}