StackOverflowException在.NETStackOverflowException、NET

由网友(素顔爲誰妝)分享简介:打了几StackOverflowExceptions在.NET后,我发现他们完全绕过了.NET提供(Application.ThreadException / AppDomain.UnhandledException)未处理的异常处理程序。这是非常令人不安的,因为我们有重要的清理code在那些异常处理程序。Afte...

打了几StackOverflowExceptions在.NET后,我发现他们完全绕过了.NET提供(Application.ThreadException / AppDomain.UnhandledException)未处理的异常处理程序。 这是非常令人不安的,因为我们有重要的清理code在那些异常处理程序。

After hitting a few StackOverflowExceptions in .NET I noticed they completely bypass the unhandled exception handlers that .NET offers (Application.ThreadException / AppDomain.UnhandledException). This is very disturbing since we have critical cleanup code in those exception handlers.

有什么办法来克服这一点?

Is there any way to overcome this?

推荐答案

不是真的;堆栈溢出或内存不足异常发生在CLR本身就意味着事情已经极其错误的范围内(通常我得到它的时候我一直是个蠢蛋,创造了递归属性)。

Not really; a stack overflow, or an out of memory exception happens within the CLR itself means something has gone critically wrong (I usually get it when I've been a dumbass and created a recursive property).

在这种状态时有没有办法为CLR分配新的函数调用或内存,使其能够调用到异常处理程序;这是一个我们必须停止现在的情景。

When this state occurs there is no way for the CLR to allocate new function calls or memory to enable it to call into the exception handlers; it's a "we must halt now" scenario.

然而,如果你抛出该异常自己的异常处理程序将被调用。

If, however, you throw the exception yourself your exception handlers will be called.

阅读全文

相关推荐

最新文章