StackOverflowException在

StackOverflowException在

本文介绍了StackOverflowException在.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

打了几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.

这篇关于StackOverflowException在.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 22:46