Application Domains in .NET
page 1 of 13
Published: 16 Aug 2006
Unedited - Community Contributed
Abstract
In this article Joydip provides a detailed analysis of Application Domains, how they work and their differences with a process.
by Joydip Kanjilal
Feedback
Average Rating: 
Views (Total / Last 10 Days): 87259/ 98

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.


View Entire Article

User Comments

Title: Answer to reader's queries   
Name: Joydip Kanjilal
Date: 2006-11-15 3:44:34 PM
Comment:
Dear All,

Thanks a lot for the comments. Please note that an Application Domain belongs to only a single process, but a single process can hold multiple Application Domains. This is what I wanted to highlight in this article. Please let me know by e-mail or otherwise, if you still have any confusions.

Regards,

Joydip.
Title: it is nice   
Name: gir
Date: 2006-11-06 7:59:31 AM
Comment:
everything is cool!
Title: Rewrite please   
Name: Juan Romero
Date: 2006-10-25 5:50:22 PM
Comment:
This is a great article but some things seem contradictory. For example "A process runs exactly one application and has its own virtual address space, executable code and data." and "Multiple applications can execute within a single process by loading them into separate application domains.".
Hopefully the author rewrites this article. It is an interesting topic.
Title: Examples would be helpful   
Name: Reader
Date: 2006-10-13 9:11:12 PM
Comment:
It would be nice to read about some examples of why I would want to use application domains. Not necessarily code to do it, but real world reasons to use them and how the system would benefit vs. not using app domains.
Title: suggestion   
Name: reader
Date: 2006-10-13 5:17:38 PM
Comment:
Every application has a process space in which it is executed. This provides isolation between processes that ensures that code in one process does not have direct access to the code in another process. An application domain is lighter than a process and therefore, it is referred to as a light weight process. Application domains are appropriate for scenarios that require isolation without the heavy cost associated with running an application within a process. In other words, an Application domain provides a secure and versatile unit of processing that the common language runtime can use to provide isolation between applications running in the managed environment of Microsoft .NET. It should be noted here that applications that run on different Application Domains can only share information by using Microsoft .NET's Remoting technology. A process is the running instance of a program and is characterized by a change of state and attributes and identified by having a Process Control Block of its own. A process runs exactly one application and has its own virtual address space, executable code and data. Like an Application Domain, a process is not permitted to access the code or data of another process. The exact behavior of a particular process is based on the operating system on which it executes. Multiple applications can execute within a single process by loading them into separate application domains.


I don't the difference between the process and app domain in the above paragraph. should be rewritten.
Title: Thread Pools in AppDomains   
Name: David Martin
Date: 2006-10-13 5:14:40 AM
Comment:
Good article. Clearly explained. It was very helpful for some of junior developers on my team.
You discuss thread relationships at the end as a one to one relationship between application domain and thread. I think this is slightly mis-laeding. The thread is abstracted from the app domain, described as a soft thread - with the true process thread described as a hard thread. The relationship between a hard thread and a soft thread is one per AppDomain, every time a hard thread enters an AppDomain it is always associated with the same soft thread of execution (unless it has changed in framework 2.0). The hard thread TLS contains data references to soft threads in different AppDomains within the same process. The CLR abstraction provides us a soft thread TLS.
So if there are 3 AppDomains each using 3 threads which would represnet 9 soft threads the process and OS may only be consuming 3 Hard (OS) threads.

I hope this is of help to someone. I have a presentation explaining this which I will upload somewhere - in the mean time if anyone wants it drop me a line at mrdavemartin@hotmail.co.uk
Title: Good   
Name: kesavan
Date: 2006-10-09 7:14:42 AM
Comment:
Nice Article
Title: App serialization and restart?   
Name: C
Date: 2006-08-31 12:09:01 PM
Comment:
Can you cover how to start an application in an application domain, pause it, save it to disk, load it back into an application domain and then restart the application from its paused state?
Title: good   
Name: sara
Date: 2006-08-31 9:27:17 AM
Comment:
very good article. many thanks to the author
Title: EXCELENT   
Name: Mahesh
Date: 2006-08-22 2:24:48 AM
Comment:
GOOD ONE
Title: acknowledgement   
Name: Sagar Debnath
Date: 2006-08-17 6:57:02 AM
Comment:
Gud article about appdomain in .net.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2017 ASPAlliance.com  |  Page Processed at 2017-04-28 2:24:30 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search