Click here to Skip to main content
15,920,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Can anyone brief me the differences between the Appdomain and Process in .net.Also,please tell me why are Appdoamins usefull.

Regards
Chaithanya M
Posted

One aspect is extremely important:

Application Domain is useful when you need to unload loaded assembly. This is not allowed by .NET due to safety purpose: what is some code will be called after unloading?

If you try to create re-loadable plug-ins, it will create a string memory leak. If you want to load a different version of the plug-in during run-time, old version will stay in memory. The only way is this: load (or compile into memory which effectively performs compile-and-load) a reloadable assembly in a separate Application Domain and used it through this domain. As the the domains are memory-isolated as strongly as processes, there is no any danger in unloading the domains, so there is an unload method of the Application Domain, with all the assemblies loaded in it.

Please see my past solution describing skeletons of architecture using this feature:
Create WPF Application that uses Reloadable Plugins...[^],
AppDomain refuses to load an assembly[^],
code generating using CodeDom[^].

—SA
 
Share this answer
 
Comments
Espen Harlinn 4-May-11 18:31pm    
My 5
Sergey Alexandrovich Kryukov 4-May-11 21:30pm    
Thank you, Espen.
--SA
First link in google when I search for "difference between AppDomain and Process":

http://www.dotnetspider.com/forum/ViewForum.aspx?ForumId=139934[^]
 
Share this answer
 
What is AppDomain?
Each application running within a process, AppDomain is also a light-weight process or we can say logical unit which having group of assemblies (this is a container which contain group of assemblies ) and this exist inside of the process at isolation level of same process, this allows to run multiple assemblies within same process and prevent them for direct access.

Running Dot Net Application Within AppDomain:
Once any dot net application run, Operation system shell load CLR into a process and new AppDomain been created in the same process and load all the assemblies in the created AppDomain, now from the AppDomain code will get executed.

When to Create Custom AppDomain:
We can create own AppDomain, now the thing is in which scenario we can create own AppDomain. Suppose run time we need to add or remove the assemblies without interruption the running application then we can create own AppDomain.

Thanks
mdafazal@gmail.com
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900