Reputation: 764
This may seem like a silly question, but no amount of Googling will give me the answer. In C#, when using the Debug.Assert
class, a failure causes a MessageBox to show. Pressing "Retry" goes to the call site in the debugger. Is there any way to do so automatically i.e. go straight to the call site (skip pressing "Retry" every time?)
Upvotes: 0
Views: 282
Reputation: 27950
Use System.Diagnostics.Debugger.Break();
to suspend execution of the process just as if a debugger breakpoint had been hit:
void DebugAssert(bool condition)
{
if(!condition)
System.Diagnostics.Debugger.Break();
}
Upvotes: 3