1
我一直在写针对.NET框架V3.5和Visual Studio的Web应用程序会出现2013年一个StackOverflowException上System.Diagnotics.StackTrace()
间接递归在它someties造成StackOverflowException我这么写一种检查堆栈溢出的方法。
public static void CheckStackOverflow() {
StackTrace stackTrace = new StackTrace();
StackDepth = stackTrace.GetFrames().Length;
if(StackDepth > MAXIMUM_STACK_DEPTH) {
throw new StackOverflowException("StackOverflow detected.");
}
}
的问题是,一个StackOverflowException在第一行中出现,即new StackTrace()
,所以我不能照顾它。
我知道调用StackTrace()也会将堆栈加深几级,所以我明白这可能会发生。然而,有一些耐人寻味:
- 选择了在Visual Studio 2012 的Visual Studio(ASP.NET)开发服务器(以下卡西尼)有没有问题,所以我的IIS设置或类似的东西是疑似。
- 堆栈在发生异常时并不够深。
这只发生在调试。不管配置如何(即调试/发布)。
编辑:我试图changed IIS Express settings和它并没有差异。此外,尝试本地IIS选项也没有运气,无论是。所以,
if(RunningWithVisualStudio) { // Start Debugging or Without Debugging
if(UsingCassini) {
throw new StackOrverflowException("A catchable exception."); // expected
} else {
throw new StackOverflowException("I cannot catch this dang exception.");
}
} else { // publish on the identical ApplicationPool.
throw new StackOrverflowException("A catchable exception."); // expected
}
我想我犯的错误配置IIS快递但我现在完全失去了。