application domains provide a flexible and secure way to isolate running applications.
Application domains are typically created and manipulated by the runtime host. Sometimes, you might want your application to programmatically interact with an application domain, such as when you want to unload a component without stopping the application from running.
application domains help improve security by separating applications and application data from each other. a single process can run multiple application domains and have an isolation level that exists in a separate process. running multiple applications in a single process improves the scalability of the server.
The following code example creates a new application domain and then loads and executes the previously generated assembly , HelloWorld.exe, which is stored on drive C.
// Create an application Domain: System.AppDomain NewDomain = System.AppDomain.CreateDomain ("newapplicationdomain") ; // Load and execute an assembly:newdomain.executeassembly (@ "c:\HelloWorld.exe" ); // Unload the application domain: System.AppDomain.Unload (NewDomain);
Application domains have the following characteristics:
Before the assembly can be executed, the assembly must be loaded into the application domain.
An error in one application domain does not affect other code that runs in another application domain.
The ability to stop a single application and unload code without stopping the entire process. You cannot unload individual assemblies or types, only the entire application domain.
Application domains (application domain)