We can define an application domain as a logical container that isolates an application instance creating boundaries for security, data access and the flexibility to unload a single application domain and all assemblies inside it without affecting other application domains within the same process.
Imagine a user accessing a .NET web site. The user has his application domain and the session objects will not be shared between users. It happens because a new application domain has been created when the user accesses that application (starting a new session). In this web example multiple application domains are within a single aspnet worker process (aspnet_wp.exe).
The ASP.NET application is a good example but you can use application domains in different scenarios. They are recommended to isolate critical assemblies, long running processes, large assemblies that might cause performance related issues or bring down an entire process. In the first application hiccup you may want to unload the application domain without affect any other part of your system.
A simple example that demonstrates the .NET AppDomain object in action and three basic tasks: create application domain, execute assembly and unload the application domain.
/// Creates a new domain
AppDomain myAppDomain = AppDomain.CreateDomain(“MyAppDomainName”);
/// Executes an assembly
/// Unloads an application domain
To get full details about application domains and how to set security properties, click here!