Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Don't stop debugger at THAT exception when it's thrown and caught

In tools/exceptions, I've set the option that the debugger stops when an exception is thrown. Whether it is caught or not .

How do I exclude an exception of that rule? Somewhere in my code there is a caught exception that is part of the program logic. So I obviously don't want that exception to stop the debugger each time it is hit.

Example: I want to ignore the nullreference exception (which is caught) on line 344 . I want to stop at all other exceptions

like image 210
MichaelD Avatar asked Sep 14 '09 08:09

MichaelD


People also ask

How do I stop exception breakpoint?

Remove breakpoints For non-exception breakpoints: click the breakpoint in the gutter. For all breakpoints: from the main menu, select Run | View Breakpoints Ctrl+Shift+F8 , select the breakpoint, and click Remove Delete .

How do I stop Visual Studio from breaking on exception?

When the debugger breaks, it shows you where the exception was thrown. You can also add or delete exceptions. With a solution open in Visual Studio, use Debug > Windows > Exception Settings to open the Exception Settings window. Provide handlers that respond to the most important exceptions.

How do I stop debug mode?

To exit debug mode, press Alt+B followed by D. at the Command Prompt to exit debug mode.

What does stop debugging do?

Debug | Stop Debugging Click Stop Debugging on the Debug menu to stop the target's execution and end the target process and all its threads. This action enables you to start to debug a different target application.


1 Answers

DebuggerHidden is your friend!

The common language runtime attaches no semantics to this attribute. It is provided for use by source code debuggers. For example, the Visual Studio 2005 debugger does not stop in a method marked with this attribute and does not allow a breakpoint to be set in the method. Other debugger attributes recognized by the Visual Studio 2005 debugger are the DebuggerNonUserCodeAttribute and the DebuggerStepThroughAttribute.

Tested on VS2010 and works great.

While DebuggerStepThrough seems to also work for some specific debugger versions, DebuggerHidden seems to work for a wider range of situations based on the comments to both answers.

Note that both options do not currently work with iterator block methods or for async/await methods. This could be fixed in a later update of Visual Studio.

Note that it does not work with combination of .NET Core + Rider, you can vote the issue.

like image 109
Shimmy Weitzhandler Avatar answered Sep 18 '22 20:09

Shimmy Weitzhandler