Application Domains in .NET
In .NET, the primary application boundary is not a process, but Application domain. Lets see some of the differences between these two
Operating System Process
- Each process has its own virtual address space, executable code, and data
- A windows process cannot directly access the code or data of another windows process
- A windows process runs only one application, so if an application crashes, it does not affect other applications
- Processes are efficient in isolating applications, but they require expensive IPC mechanisms to communicate
- A process is a vary low level operating system construct; the exact behavior of a process is determined by the operating system. Thus a windows 2000 process is very different from a Unix process
Remember, when a processor switches between processes, the processor must save and reset the execution context of the processes. This takes lot of resources
Instead of a process, the basic unit of isolation for running applications in the CLR is an application domain. CLR allows several application domains to run within a single windows process
Application domain:
- An application domain is the .NET runtime’s representation of a logical process
- Each application domain contains its own set of code, data and configuration settings
- An application domain cannot directly access the code or data structures of another application domain
- Code running in one application domain cannot affect other application domains. CLR can terminate an application domain without stopping the entire process
- Application domain hides operating system’s details of a process. This allows .NET to be ported to a variety of operating systems
- Application domains allow the .NET runtime to optimize communication between applications running in the same process where expensive IPC mechanisms are not required
An Application domain can be created using AppDomain class of System namespace. However, in most cases the application domains created and managed by the runtime hosts that execute your code. Runtime hosts provide the environment to run managed code on behalf of the user. The following three runtime hosts come with .net installation
Windows shell
ASP.NET
Internet Explorer
Comment Notification
If you would like to receive an email when updates are made to this post, please register here
Subscribe to this post's comments using
Comments