Miscellaneous Concepts of .NET – Part 1
page 6 of 9
by Uday Denduluri
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 41016/ 73

Creating Application Domains and Executing User code

The host can create application domains to run user code with security, isolation and unloading. It is not a better idea to run user code in the default domain. Let us list down the reasons for the same:

·         A default domain cannot be unloaded until the process exists

·         Security Isolation

Now that the host has created an application domain, we can execute user code in the domain. All code that is run in the CLR must be part of an assembly. An assembly is the deployment unit for types and resources and is the primary unit of execution in the CLR. The manner in which assemblies are loaded for execution depends largely on the host's specific scenario.

In general, there are two options:

·         The first option is to load precompiled assemblies from a disk.

·         The second option is to create assemblies on the fly using the API's in the System.Reflection.Emit namespace.

The code shown in Listing 2 is for creating an ApplicationDomain and executing an assembly into it. The code is written in C#. The Assembly that is loaded is an exe file.

Listing 2

ObjAppDomain = AppDomain.CreateDomain("My Application 1");
ObjAppDomain.ExecuteAssembly(@"C:\APPDOMAIN_Test.exe");

The code shown below is for unloading the Application domain from the memory.

Listing 3

AppDomain.Unload(ObjAppDomain);

View Entire Article

User Comments

Title: Good One   
Name: Shilpa Ginode
Date: 5/6/2008 2:52:19 AM
Comment:
Good article on Application Domain.
i learned this concept from this article.
Title: Good   
Name: pankaj
Date: 7/18/2007 8:00:21 AM
Comment:
good
Title: Thanks   
Name: Leonzhu
Date: 5/7/2007 10:31:56 AM
Comment:
Thanks for your excellant article
Title: Good Article on Application Doamin   
Name: Bhavannarayana.aluri
Date: 4/30/2007 1:11:05 AM
Comment:
Nice article on Application domain
Title: Excellant   
Name: Joydip
Date: 4/26/2007 3:17:22 AM
Comment:
This is an outstanding article Uday. Keep it up. I would like to see more articles of this kind from you.

Product Spotlight
Product Spotlight 





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


©Copyright 1998-2014 ASPAlliance.com  |  Page Processed at 12/20/2014 7:25:14 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search