.net中AppDomain和Process之间的区别 [英] Difference between AppDomain and Process in .net

查看:70
本文介绍了.net中AppDomain和Process之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





任何人都可以向我介绍Appdomain和.net之间的差异。还请告诉我为什么Appdoamins有用。



问候

Chaithanya M

解决方案

一方面非常重要:



当您需要卸载已加载的程序集时,Application Domain非常有用。由于安全目的,.NET不允许这样做:卸载后会调用哪些代码?



如果您尝试创建可重新加载的插件,它将创建一个字符串内存泄漏。如果要在运行时加载不同版本的插件,旧版本将保留在内存中。唯一的方法是:在单独的应用程序域中加载(或编译到有效执行编译和加载的内存中)可重新加载的程序集,并通过此域使用它。由于这些域与进程一样具有内存隔离性,因此卸载域没有任何危险,因此应用程序域有一个卸载方法,其中包含所有程序集。



请参阅我过去使用此功能描述架构骨架的解决方案:

创建使用可重新加载插件的WPF应用程序...... [ ^ ],

AppDomain拒绝加载程序集 [ ^ ],

[ ^ ]。



-SA


< blockquote>当我搜索AppDomain和Process之间的区别时谷歌中的第一个链接:



http://www.dotnetspider.com/forum/ViewForum.aspx?ForumId=139934 [ ^ ]


什么是AppDomain?

每个应用程序在一个进程中运行,AppDomain也是一个轻量级的进程,或者我们可以说具有一组程序集的逻辑单元(这是一个包含程序集组的容器)并且它存在于在同一进程的隔离级别进程,这允许运行多个组合在相同的过程中并阻止它们直接访问。



在AppDomain中运行Dot Net应用程序:

一次任何dot net应用程序运行,操作系统shell将CLR加载到进程中并在同一进程中创建新的AppDomain并加载创建的AppDomain中的所有程序集,现在从AppDomain代码将被执行。



何时创建自定义AppDomain:

我们可以创建自己的AppDomain,现在我们可以创建自己的AppDomain。假设运行时我们需要添加或删除程序集而不中断运行的应用程序然后我们可以创建自己的AppDomain。



谢谢

mdafazal @ gmail.com

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

解决方案

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


First link in google when I search for "difference between AppDomain and Process":

http://www.dotnetspider.com/forum/ViewForum.aspx?ForumId=139934[^]


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


这篇关于.net中AppDomain和Process之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆