Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force VS2019 ignore exceptions inside "try" section

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

like image 417
Vlad Kravchenko Avatar asked Oct 19 '25 14:10

Vlad Kravchenko


1 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.

like image 171
Mr Qian Avatar answered Oct 21 '25 02:10

Mr Qian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!