Continued in Visual Studio debugger after exception

When I debug a C # program and I get an excluded thrown (either thrown by code or created by the framework), the IDE stops and returns me to the corresponding line in my code.

Now everything is all right.

Then press "F5" to continue. From now on, he stitches, as if I'm in an endless loop. The IDE always returns me to the exception string. I have to Shift + F5 (stop debugging / terminating the program) to exit it.

I talked to some of the staff here, and they told me that this happens to them as well.

What's happening?

+42
debugging c # exception
Oct 02 '08 at 20:31
source share
5 answers

This is because the exception is not handled, and Visual Studio cannot move along this line without processing it in any way. Simply put, this is by design.

One thing you can do is drag the execution point (yellow line / arrow) to the previous point in the code and change the values ​​in memory (using the Visual Studio viewport) so that they don't throw an exception. Then go through code 1 again.

It is best to stop execution and fix the problem causing the exception, or handle the exception correctly if the throw is not needed.

1 This can have unintended consequences, as you essentially re-execute some code (without rewinding the execution).

+16
Oct 02 '08 at 20:41
source share

You probably have the option β€œ Unbind column on unhandled exceptions ” in Visual Studio. When this option is in Visual Studio, it will expand until the exception itself, so pressing F5 will continue to work in the same exception.

If you disable the Visual Studio option, it will be broken into an exception, but pressing F5 will go through this line.

This option is located in the menu Tools β†’ Options β†’ Debugging β†’ General.

+43
Apr 11 '14 at 3:06
source share

When the IDE breaks into an offensive line of code, it stops just before the line that throws the exception is executed. If you continue, it will execute this line again and get an exception again.

If you want to bypass the error to find out what would have happened if the error had not occurred, you can drag the yellow highlighted line (the line that will be executed further) to the next line of code after violation one. Of course, depending on what could not be executed in the line of violation, your program may now be in a state that causes other errors, in which case you have not helped yourself very much and probably should fix your code so that the exception either not executed 't happening or being handled properly.

+4
Oct 02 '08 at 20:43
source share

Once you get the exception, Visual Studio (or any other IDE you could use) will not let you go further if the exception is not handled in your code.

This is design behavior.

+3
02 Oct '08 at 20:39
source share

Continuous exclusion will reduce your application. Instead, VS will simply take you away from the uncaught exception, you will have to stop or use the feedback from your application.

+2
Oct 02 '08 at
source share



All Articles