如何理解AppDomain隔离提供的可靠性? [英] How to understand the reliability provided by AppDomain Isolation?

查看:135
本文介绍了如何理解AppDomain隔离提供的可靠性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对在MSDN中对AppDomain的描述感到困惑. [

I got confused about the description of AppDomain in MSDN.[^]

It''s said:
Faults in one application cannot affect other applications. Because type-safe code cannot cause memory faults, using application domains ensures that code running in one domain cannot affect other applications in the process.

But any unhandled exception in any thread, no matter which AppDomain the code runs in, will cause the entire process crash. So how to understand the reliability provided by AppDomain?

推荐答案

您的主要问题是您使用的崩溃"概念不足.
本质上,如果您考虑一下,在应用程序中具有未处理的异常严格等同于从入口点方法退出.您沿着某个线程的堆栈进行了一些异常传播.当指令流使用异常机制跳到堆栈的顶部,并且没有使用顶层try-catch块时,应用程序除了终止线程外没有任何关系.如果它是进程中的唯一线程,则该进程终止.但是,即使终止进程也不总是总是发生,因为它可以是其他一些线程,而不是入口点之一.

现在,Application Domain并没有太大改变.实际上,应用程序域可以共享线程,因此可以共享它们的堆栈.因此,您可以在try-catch下在一个应用程序域中进行调用,在另一个应用程序域中引发一个异常,但不进行处理(这实际上很好).在这种情况下,异常将传播回调用方应用程序域.并且,可以选择将其捕获.

这甚至不会降低可靠性,但是,如果在每个线程的堆栈顶部正确地处理了异常(无论使用哪个应用程序域),都可以大大改善.

—SA
You main problem is that you are using inadequate notion of "crash".

In essence, having unhandled exception in an application is strictly equivalent to exit from the entry point method, if you think about it. You have some exception propagation along the stack of some thread. When the instruction flow jumps to the top of the stack with exception mechanism, and top-level try-catch block was not used, the application has nothing to do but terminate the thread. If it was the only thread in the process, the process terminates. But even termination of the process does not always happen, because it can be some other thread, not the one of the entry point.

Now, Application Domain does not change this picture much. Actually, Application Domains can share threads and hence, the stacks of them. So, you can make a call in one Application Domain under try-catch, have an exception thrown in another Application Domain, not handled (which is actually good). In this case, the exception will propagate back to the calling Application Domain. And, optionally, caught there.

This does not reduce reliability even a bit, but, if exception is properly handled on top of stack of each thread (no matter which Application Domain), can greatly improve it.

—SA


这篇关于如何理解AppDomain隔离提供的可靠性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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