CodeKicks.com
Focus on Microsoft Technologies - Tutorials, Articles, Code Samples.

Monday, September 04, 2006

.NET Application Domains

Introduction

An Application Domain is a light-weight process.  It is a logical and physical unit of isolation built around every .NET application by the Common Language Runtime (CLR) and contains its own set of code, data and configuration settings.  Multiple application domains can exist simultaneously in the same process.  The default application domain is created when the Common Language Runtime is first loaded into a process.  From then on, the CLR loads an assembly implicitly into an Application Domain the first time it encounters and references a type in the MSIL code. Assemblies can also be created explicitly loaded in Application Domains.  This article discusses what Application Domains are and the differences between Application Domains and Processes.  It also discusses Default Domains and how Application Domains can be created, loaded and unloaded explicitly.

 

What is an Application Domain?

An Application Domain is a light weight process and provides a logical and physical isolation from another .NET application.  This ensures that the Applications can work independent and isolated of each other.  An Application Domain is created by the Common Language Runtime (CLR) and it ensures that if one Application Domain crashes or goes down, it does not in any way effect the functioning of another Application Domain.  Multiple .NET applications can be executed in one single process by loading these applications in separate Application Domains.  Several threads can be executing in a single application domain at any given time and a particular thread is not confined to a single application domain.  In other words, threads are free to cross application domain boundaries and a new thread is not created for each application domain.  The following are the benefits of Application Domains.Isolation of code, data and configuration information of one application from another A failure in one application will not affect the other

 

What are Runtime Hosts?

When we create an application in .NET, regardless of the type of the application (Console Applications, Windows applications, Web services, etc), it has to be hosted by a Win32 process.  This is because none of these are Win32 applications.  This process is what we call the Runtime Host.  The following are the runtime hosts shipped with .NET Framework: ASP.NET, IE and Shell.  It is also possible to write our own Runtime host using some Microsoft APIs.

Continue

Post a Comment