检查外部代码框抛出的System.TypeInitializationException中的InnerException

时间:2013-12-06 15:22:02

标签: c# visual-studio-2012 inner-exception

使用Visual Studio 2012 Express,如何从外部代码框架中InnerException时检查System.TypeInitializationException。调试器因异常而中断,但不在任何代码行。它给出了以下信息:

No Source Available
The call stack contains only external code.
Thi thread is stopped with only external code frames on the call stack. External code frames are typically from framework code but can also include other optimized modules which are loaded in the target process.

然后给出调用堆栈,见下文:

enter image description here

我会设置一个try-catch块,但我不知道代码在哪里发生。我如何在此时检查InnerException?有没有其他方法可以找到什么?

1 个答案:

答案 0 :(得分:1)

此类异常的Repro代码,其中堆栈跟踪看起来与您的完全相同:

class Program {
    static Program() {
        throw new Exception("kaboom");
    }
    static void Main(string[] args) {
    }
}

您应该使用在抛出异常时弹出的异常助手。点击“查看详细信息”:

enter image description here