C#赶上堆栈溢出异常 [英] C# catch a stack overflow exception
问题描述
我得到抛出一个堆栈溢出异常的梅索德递归调用。第一个通话会被try catch块包围,但例外没有被捕获。
I got a recursive call to a methode that throw a stack overflow exception. The first call is surrounded by a try catch block but the exception is not caught.
不要堆栈溢出异常行为以特殊的方式?我能赶上/妥善处理异常?
Do the stack overflow exception behave in a special way ? Can I catch/handle properly the exception ?
注意:如果相关的:
-
的异常没有在主线程抛出
the exception is not thrown in the main thread
其中code抛出异常被手动Assembly.LoadFrom(...)加载的对象。的CreateInstance(...)
the object where the code is throwing the exception is manually loaded by Assembly.LoadFrom(...).CreateInstance(...)
推荐答案
2.0启动的StackOverflow异常只能在下列情况下抓住了。
Starting with 2.0 a StackOverflow Exception can only be caught in the following circumstances.
- 的CLR正在在托管环境中,主机指定允许进行处理StackOverflow的异常运行
- 的计算器异常是由用户code抛出,而不是由于实际的堆栈溢出情况(<一个href=\"http://blogs.msdn.com/jaredpar/archive/2008/10/22/when-can-you-catch-a-stackoverflowexception.aspx\">Reference)
- The CLR is being run in a hosted environment where the host specifically allows for StackOverflow exceptions to be handled
- The stackoverflow exception is thrown by user code and not due to an actual stack overflow situation (Reference)
这篇关于C#赶上堆栈溢出异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!