Application Domain in .NET Framework

In the Common Language Runtime, an application domain is a mechanism (similar to a process in an operating system) used to isolate executed software applications from one another so that they do not affect each other. Each application domain has their own virtual address space which scopes the resources for the application domain using that address space.

A Common Language Runtime application domain is contained within an operating system process. A process may contain many application domains. This carries major advantages:
  • There is lower system cost.
  • Multiple threads can exist within a single application domain.
  • The application in a domain can be stopped without affecting the state of another domain in the same process.
  • A fault or exception in one domain does not affect an application in another domain or crash the entire process that hosts the domains.
  • Configuration information is part of a domain's scope, not the scope of the process.
  • Each domain can be assigned different security access levels, all within a single process.
  • Code in one domain cannot directly access code in another.
In this sense, the CLR is like a mini-operating system. It runs a single process that contains a number of sub-processes, or application domains.

An application domain represents isolation/scoping unit for a .NET
application. .NET allows multiple applications to be loaded in a single process. It achieves this by loading each application in its own independent application domain.

Each application domain is isolated from all other application domains. You can think of application domains as lightweight processes with a process. This is more efficient than creating a separate process for each application and provides the same benefit (isolation).

Use System.AppDomain to create application domains programmatically. CLR itself runs in an application domain called the default domain.
Tags: ,
Hot on Web:


About author