Any equivalent to debug.assert?

  • Thread starter Thread starter Brian Cryer
  • Start date Start date
B

Brian Cryer

It would be very handy to be able to stop the debugger on parts of code
without having to explicitly set a breakpoint - either a "debugger.break" or
"debug.assert" type of thing would do. I've not come across anything, but is
there anything in (VB).NET that would allow me to do this?

TIA.
 
re:
!> is there anything in (VB).NET that would allow me to do this?

No, there isn't any native support for debug.assert,
but you can roll your own version quite easily, thanks to Dr. DotNetsky:

http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=573

Compile the code in that page to an assembly, place the assembly in the
bin directory of your app, and add the Assert Handler to your app in Global.asax,
per the code supplied.

Voila! You have a debug.assert handler.

It will only fire in Debug mode and when running in localhost.




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
 
Thank you Juan.

This is great.

Since mostly I want to break on some of my exception handling I can probably
simply add:
If System.Diagnostics.Debugger.IsAttached Then
System.Diagnostics.Debugger.Break()
End If


but I wouldn't have found it except for you posting the link (and I'll
probably import it in full later). Thank you.
 
Back
Top