查找VS输出窗口中显示的异常源 [英] Find source of Exception shown in VS output window
问题描述
在VS2013中运行应用程序时,出现以下异常:
类型为 System.InvalidOperationException的首次机会异常
发生在mscorlib.dll中
和
mscorlib.dll中发生了类型为'System.InvalidOperationException'
的第一次机会异常
在任何地方都可以捕获此异常由于我的应用程序不会崩溃,因此一切正常。
但是我真的很想找到导致此异常的代码部分来解决这个问题。
我该怎么办才能找出代码的哪一部分抛出了这个问题异常或发生的地方。有没有一种方法可以在VS中显示/可视化?调试器选项?
我该怎么做才能找出代码的哪一部分抛出此异常或在哪里抛出该异常发生。有没有一种方法可以在VS中显示/可视化?
在Visual Studio中,选择 Debug ,然后选择 Exceptions 。 / p>
在例外窗口中,在公共语言运行时例外行上勾选抛出。
点击确定
现在,每当引发异常时,调试器就会在有问题的行上中断。您还可以扩展选择范围,使其仅包括感兴趣的例外。
Visual Studio 2017
您可以找到在 Debug.Windows.Exception设置
下
When running my application in VS2013 I get the exceptions:
A first chance exception of type 'System.InvalidOperationException' occurred in mscorlib.dll
and
A first chance exception of type 'System.InvalidOperationException' occurred in mscorlib.dll
This exceptions are caught anywhere since my application does not crash, everything works "normal". But I would really like to find the code section causing this exceptions to solve this.
What can I do to find out which part of my code throws this exception or where it happens. Is there a way to show/visualize this in VS? Debugger options?
What can I do to find out which part of my code throws this exception or where it happens. Is there a way to show/visualize this in VS? Debugger options?
In Visual Studio, choose Debug then Exceptions.
In the Exceptions window, tick Thrown on the Common Language Runtime Exceptions row.
Click OK.
Now whenever an exception is thrown, the debugger will break on the offending line. You can also expand the selection to only include the exceptions of interest.
Visual Studio 2017
You can find this under Debug.Windows.Exception Settings
这篇关于查找VS输出窗口中显示的异常源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!