Is there any way to cause Visual Studio 2010 to break while debugging when the argument of Debug.Assert
evaluates to false
?
Example: in my code I have lines like this:
Debug.Assert(!double.IsInfinity(x));
If I am not debugging, a window pops up when the assertion fails.
But when I am debugging, the assertion is logged to the "Output" pane, which is easy to miss; there is not popup window and the debugger does not stop. Therefore: is there any way to force the Visual Studio debugger to break when Debug.Assert
fails?
(BTW: I am developing a WPF based desktop application. In a Windows Forms application, the behavior seems to be differnt: here, the debugger stops on Debug.Assert
.)
EDIT: Please let me clarify: I am not looking for an alternative to Debug.Assert(), because my code and external code I use is full of Debug.Assert() statements. I am looking for a way to cause the Visual Studio debugger to break when Debugg.Assert
fails. (I think earlier VS versions did that, and that the behavior changed in VS2010).
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…