How to jump back to the line of code that threw exception in Visual Studio 2010 debugger?

六月ゝ 毕业季﹏ 提交于 2020-01-12 14:00:35

问题


Using the Visual Studio 2010 debugger, I am familiar with using the Call Stack window to see where the currently executing function was invoked from.

I'm working with some applications that have rather large try blocks. Supposing that I pause execution of the code at a break point in the catch block, what is the simplest way to tell which line in the try block the exception was raised from?

I do know that the "Stack Trace" includes details such as the line number, but is there an easier way, such as a shortcut key, to navigate back to the line of code where the exception was raised?

Update: I would like to emphasize that I don't wish to move the execution point back to the try block; I simply want a simpler way of knowing which line the exception was raised from.


回答1:


If you goto "DEBUG", "Exceptions..." and then select "Thrown" against "Common Language Runtime Exceptions".

Then when your code encounters an exception it will stop on the line with the error.




回答2:


A solution might be to make VS break on all exceptions:

Select Exceptions under the Debug menu, and check the "Thrown" box related to Common Language Runtime Exceptions.

Now VS should now stop and mark the line where the exception is thrown. You can continue as usual, by clicking the play button or F5.

The downside of this is that all exceptions will be caught in the same way, which may be annoying if you have a lot of them.



来源:https://stackoverflow.com/questions/15010935/how-to-jump-back-to-the-line-of-code-that-threw-exception-in-visual-studio-2010

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