How to force VS2019 ignore exceptions inside "try" section

Viewed 1810

Just installed VS2019 and noticed one uncomfortable thing: in Debug it stops ("falls") at the each exception, even inside try sections. How can I force it to ignore these exceptions, go to catch and work further?

After answer of Perry Qian-MSFT. Now I see this when I have UNHANDLED exception.

Translation: "application is in pause mode". And call stack is empty. After answer of Perry Qian-MSFT. Now I see this when I have UNHANDLED exception

3 Answers

How to force VS2019 ignore exceptions inside “try” section

First, I agree with dixv and thanks for his help.

Current VS IDE can ignore specific exceptions as required.Under Debug-->Windows-->Exception settings

You can record the previous exception's name and search under it and then uncheck it.

enter image description here

Note

After that, please uncheck Just My Code option, otherwise the exception may still be interrupted.

Tools-->Options-->Debugging-->General-->Just My Code

Update 1

If you enable that feature and also want to see the detailed info about that exception without breaking Debugging, you can add these code in catch

 try
{

xxxxxxxxxxxxxxx

}
catch (Exception e) {

    Debug.WriteLine("=============================");
    Debug.WriteLine(e.Message);
    Debug.WriteLine(e.Source);
    Debug.WriteLine(e.StackTrace);
    Debug.WriteLine("============================="); 

}

It will show the specific info about that exception in output window:

enter image description here

More info, you can refer to this issue.

Update 2

When you face that situation, you can just click on View Detail of that exception window, it will call Watch Widow and then when you click on StackTrace, it will show the related error file name and related line to you.

enter image description here

Hope it will help you.

Appears, there're two possible ways to... not solve this issue, but at least make it less uncomfortable.

1) Update 2 from Perry Qian-MSFT

2) I enabled Diagnostic Tools while debugging and when exception appears, I just select it in the log of the DiagTools and VS shows me required line.

You probably have the debugger set to break on first chance exceptions, which means it will break when the exception is thrown regardless of any code to catch it. To prevent this behavior, uncheck the respective exception types under Debug / Windows / Exception Settings.

From Manage exceptions with the debugger in Visual Studio:

The debugger can break execution at the point where an exception is thrown, so you may examine the exception before a handler is invoked. [...]

If you select an exception in the Exception Settings window, debugger execution will break wherever the exception is thrown, no matter whether it's handled. Now the exception is called a first chance exception.

Related