简体   繁体   中英

C# Exception Debugging - How to go back and resume exception line

In the good old days of VB6 when debugging an error I would temporarily type Resume within an error handler to take me back to the line which had caused the error.

Is there a way to do the same thing in C#? I am not talking about a permanent way to go back, this is just when you are debugging and you want to know which line caused the exception which you are currently in the catch statement for.

So just to be clear.

  1. I know something is causing an exception so I put a break point on the catch statement
  2. The debugger hits the break point in the catch, I want to know which line caused it and take the debugger back to it.

I can't use the Debug > Options - throw on all exceptions as there are other exceptions in the app silently occurring (I didn't write it).

Thanks

您需要继续退出catch语句,然后可以“设置下一条语句”或将黄色箭头向上拖动到try语句的开头。

The stack trace in the exception will tell you what line it occurred on. You can then drag the yellow arrow back up to that line and resume debugging from there.

The best idea would probably to put a breakpoint at the beginning of the try block, if you then step through that block it will show you where the error is.

Alternatively, remove the try and catch temporarily and visual studio will halt execution at the line that threw the exception because the exception won't be caught.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM