4

We have 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 a debugger attached, everything runs fine. However, if we debug the code, we don't get to point [1] but [2]. As far as I understand the language specification this should not be possible.

Even weirder, this code used to run fine even while debugging. The strange behavior started only a few days ago.

Thomas Freudenberg
  • 5,048
  • 1
  • 35
  • 44

2 Answers2

1

Check that you have done a full rebuild and are using the correct pdb files. Also check that you don't have some conditionally compiled code changing things (i.e. code between #if DEBUG statements).

slugster
  • 49,403
  • 14
  • 95
  • 145
1

Depending on original sources, it may be related to this issue : Why can't I catch a generic exception in C#?

Community
  • 1
  • 1
Guillaume
  • 12,824
  • 3
  • 40
  • 48