Resharper StackOverflowException 异常
Resharper StackOverflowException
有时当我 运行 我的单元测试时,测试 运行ner 抛出一个 WhosebugException
。有没有办法查看哪个测试可能导致问题。因为我无法确定问题出在哪里。
有什么建议吗?或者这个问题的一般原因?
来自 WhosebugExceptions 上的 MSDN 页面:
In the .NET Framework 1.0 and 1.1, you could catch a WhosebugException object (for example, to recover from unbounded recursion). Starting with the .NET Framework 2.0, you can’t catch a WhosebugException object with a try/catch block, and the corresponding process is terminated by default. Consequently, you should write your code to detect and prevent a stack overflow. For example, if your app depends on recursion, use a counter or a state condition to terminate the recursive loop. The following example uses a counter to ensure that the number of recursive calls to the Execute method do not exceed a maximum defined by the MAX_RECURSIVE_CALLS constant
所以这使得 Resharper 也很难捕捉 WhosebugException
s。你应该检查你的代码,看看是否有无穷无尽的递归调用,比如方法、函数、属性。除此之外,您可以尝试我分享的 MSDN
link 中的代码。但是你别无选择。
有时当我 运行 我的单元测试时,测试 运行ner 抛出一个 WhosebugException
。有没有办法查看哪个测试可能导致问题。因为我无法确定问题出在哪里。
有什么建议吗?或者这个问题的一般原因?
来自 WhosebugExceptions 上的 MSDN 页面:
In the .NET Framework 1.0 and 1.1, you could catch a WhosebugException object (for example, to recover from unbounded recursion). Starting with the .NET Framework 2.0, you can’t catch a WhosebugException object with a try/catch block, and the corresponding process is terminated by default. Consequently, you should write your code to detect and prevent a stack overflow. For example, if your app depends on recursion, use a counter or a state condition to terminate the recursive loop. The following example uses a counter to ensure that the number of recursive calls to the Execute method do not exceed a maximum defined by the MAX_RECURSIVE_CALLS constant
所以这使得 Resharper 也很难捕捉 WhosebugException
s。你应该检查你的代码,看看是否有无穷无尽的递归调用,比如方法、函数、属性。除此之外,您可以尝试我分享的 MSDN
link 中的代码。但是你别无选择。