How do I enable Visual Studio 2010 to break when a first chance exception happens?

牧云@^-^@ 提交于 2019-11-26 15:59:43

问题


I was reading Stack Overflow question How can I set Visual Studio to show a stack trace for first chance exceptions? regarding debugging first chance exceptions on Visual Studio 2010, and I am not able to find this option.

How can I enable Visual Studio 2010 to break exactly when a first chance exception happens?


回答1:


You may want to check the Debug menu in Visual Studio 2010. In there you will find the Exception submenu, in where you can select which type of exception you want Visual Studio to stop.

Setting the debugger to break when an exception is thrown

The debugger can break execution at the point where an exception is thrown, giving you a chance to examine the exception before a handler is invoked.

In the Exception Settings window, expand the node for a category of exceptions (for example, Common Language Runtime Exceptions, meaning .NET exceptions), and select the check box for a specific exception within that category (for example System.AccessViolationException). You can also select an entire category of exceptions.

If you check a given exception, debugger execution will break wherever the exception is thrown, regardless of whether it is handled or unhandled. At this point the exception is called a first chance exception.

See How to: Break When an Exception is Thrown for more info.




回答2:


In Visual Studio to enable 1st chance exceptions we can open the exceptions window and check the throw CLR Exception chekbox.

On the debug menu select exceptions. (Ctrl + Alt + E)

There is a Common Language Runtime Exception Thown checkbox that we can check; then click OK.

The screen show below is from VS2012:

Hope this helps



来源:https://stackoverflow.com/questions/8218249/how-do-i-enable-visual-studio-2010-to-break-when-a-first-chance-exception-happen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!