Exceptions not caught

We have the following code:

try { // some code throwing MyException } catch (MyException ex) { // [1] // no (re)throw here } catch (Exception ex) { if (ex is MyException) { // [2] } } 

If we run the code without an attached debugger, everything will work fine. However, if we debug the code, we cannot specify [1] but [2]. As far as I understand the language specification, this is not possible.

Even stranger, this code is used perfectly, even during debugging. Strange behavior began just a few days ago.

+4
source share
2 answers

Depending on the source, this may be due to this problem: Why can't I get a general exception in C #?

+1
source

Make sure you complete the rebuild and use the correct pdb files. Also, make sure that you do not have some conditionally compiled code changes (for example, code between #if DEBUG statements).

+1
source

Source: https://habr.com/ru/post/1303435/


All Articles