简体   繁体   English

应用程序域如何在异常处理中有用?

[英]How application domain can be useful in exception handling?

I know little bit about the concept of application domain. 我对应用程序域的概念了解甚少。 We can delete the appdomain to unload the dll. 我们可以删除appdomain来卸载dll。 Is it possible to use appdomain for better exception handling? 是否可以使用appdomain进行更好的异常处理? How it can be used? 如何使用?

As far as I know loading modules in child AppDomains will not offer better exception handling. 据我所知,在子AppDomains加载模块不会提供更好的异常处理。 In the MSDN page for AppDomain.UnhandledException Event it remarks that: AppDomain.UnhandledException事件的MSDN页面中,它指出:

Starting with the .NET Framework version 2.0, this backstop for unhandled exceptions in child threads was removed, because the cumulative effect of such silent failures included performance degradation, corrupted data, and lockups, all of which were difficult to debug. 从.NET Framework 2.0版开始,删除了子线程中未处理异常的支持,因为此类静默故障的累积影响包括性能下降,数据损坏和锁定,所有这些都很难调试。

This means that an unhandled exception in a child thread even if the code is executed in a child AppDomain, will bring the whole process down. 这意味着,即使代码在子AppDomain中执行,子线程中未处理的异常也会使整个过程失败。

Usually child AppDomains are used for the assembly unload feature that you mention, and for executing code in a sandbox (restricted security environment). 通常,子AppDomains用于您提到的程序集卸载功能,以及用于在沙箱(受限的安全环境)中执行代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM