views:

126

answers:

2

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 run fine even while debugging. The strange behavior started only a few days ago.

+1  A: 

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
+1  A: 

Depending on original sources, it may be related to this issue : http://stackoverflow.com/questions/1577760/why-cant-i-catch-a-generic-exception-in-c

Guillaume