ASP.NET & Assertions

  • Thread starter Thread starter Tyrant Mikey
  • Start date Start date
T

Tyrant Mikey

Do assertions not work in ASP.NET because it is a "service" type
application?
 
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>).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Profiling/Debugging Real Time Security Checks 1
assert(string msg) 2
Code Access Security Question 1
Windows XP Assertion failed 3
Unable to Get Assertions to Fail Properly 1
Assertion failed 1
Analysing mfc/atl assertions 1
assert 17

Back
Top