Exceptions not being caught
We have following code:
try
{
// some code throwing MyException
}
catch (MyException ex)
{
// [1]
// no (re)throw here
}
catch (E开发者_运维技巧xception 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.
Depending on original sources, it may be related to this issue : Why can't I catch a generic exception in C#?
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).
精彩评论