Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Common uses and best practices for application domains in .NET?

What are some guidelines and best practices for when to create new application domains within an application?

Also, what are some common uses and examples of how multiple application domains are used whithin an application?

like image 477
Taylor Leese Avatar asked Oct 28 '09 18:10

Taylor Leese


People also ask

What is the use of application domain?

Application domains provide an isolation boundary for security, reliability, and versioning, and for unloading assemblies. Application domains are typically created by runtime hosts, which are responsible for bootstrapping the common language runtime before an application is run.

What is an example of an application domain?

Application domains include banks, insurance companies, or hospitals. In this book, equipment management for a small software company is our main example. Internet applications have become increasingly important, especially for the home and entertainment domains.

What is the difference between application domain and solution domain?

The solution domain describe one of possibly many solutions to a problem. One solution might be a streamlined process, another might be an application that takes over parts of a process. An application domain would fall under the solution domain.

How many application domain can be used in single process?

Process A runs managed code with one application domain while Process B runs managed code has three application domains. Note that Process C which runs unmanaged code has no application domain. Code and data are safely isolated using the boundary provided by the AppDomain.


1 Answers

The most common scenario I've seen is to be able to provide extensibility with a different security model than the main program.

Loading a plugin in a separate AppDomain allows two things:

  1. You can implement a more restricted security model
  2. You can prevent the plugin from tearing down your application if it's buggy

Another nice use of AppDomains are to load and inspect an assembly. Doing this in a separate AppDomain allows you to glean information (or run code) from a separate assembly, then unload the entire assembly from your process's space. If you load the assembly directly, there is no way to unload it. This is also useful if you want to be able to, at runtime, "upgrade" a type to a new version (ie: load a remote assembly, and reload it later).

like image 179
Reed Copsey Avatar answered Sep 28 '22 16:09

Reed Copsey