ASP.NET & Assertions

  • Thread starter Thread starter Tyrant Mikey
  • Start date Start date
Well, just about any kind of assertion.

Debug.Assert(False)

That should stop the code and display a messagebox detailing the
assertion. But it doesn't. The text goes to the trace window, but I
want it to STOP my program. (You know, like an assertion failure SHOULD
do.)
 
Tyrant Mikey said:
Well, just about any kind of assertion.

Actually, System.Diagnostics.Debug is far from the only class with an Assert
method...
Debug.Assert(False)

That should stop the code and display a messagebox detailing the
assertion. But it doesn't. The text goes to the trace window, but I
want it to STOP my program. (You know, like an assertion failure SHOULD
do.)

See http://www.codeproject.com/aspnet/ASPNetDebugAssertion.asp for a way to
implement this. As for your original question of why it doesn't work as
expected automatically, my best guess would be that someone at Microsoft
decided this would probably cause too much pain when applications are
incorrectly deployed with debug configurations (which happens more often
than most of us might like to admit <g>).
 
Back
Top