C#中AppDomain的使用 [英] Usage of AppDomain in C#
问题描述
AppDomains 在 C# 中最重要的用途是什么?
What is the most important use of AppDomains in C#?
推荐答案
唯一最重要的用途是您的代码必须有一个 - 即您编写的所有内容C# 在 AppDomain
中执行.这很重要;-p
The single most important use is that your code has to have one - i.e. everything you write in C# executes in an AppDomain
. That is quite important ;-p
如果您的意思是附加应用域:
If you mean additional app-domains:
当使用插件和其他不受信任的代码时,它允许您隔离和卸载它们(您不能卸载程序集 - 只能卸载整个应用程序域).
When using plugins and other untrusted code, it allows you both isolation, and the ability to unload them (you can't unload assemblies - only entire app-domains).
我目前使用它来加载动态生成的 dll,以便我可以卸载它们.
I'm using it currently to load dynamically generated dlls, so that I can unload them.
它们还允许您设置不同的配置文件、信任级别等 - 但会产生相关的复杂性和远程处理成本.
They also allow you to set different configuration files, trust levels, etc - but have associated costs of complexity and remoting.
MSDN 有一个关于应用域的部分,此处.
MSDN has a section on app-domains, here.
这篇关于C#中AppDomain的使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!