Any equivalent to debug.assert?

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.
 
J

Juan T. Llibre

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.
 
B

Brian Cryer

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.
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top