Any equivalent to debug.assert?

Discussion in 'ASP .Net' started by Brian Cryer, Apr 30, 2007.

  1. Brian Cryer

    Brian Cryer Guest

    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.
    --
    Brian Cryer
    www.cryer.co.uk/brian
     
    Brian Cryer, Apr 30, 2007
    #1
    1. Advertising

  2. 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/
    ===================================
    "Brian Cryer" <brianc@127.0.0.1.activesol.co.uk> wrote in message
    news:eKNYR%...
    > 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.
    > --
    > Brian Cryer
    > www.cryer.co.uk/brian
    >
    >
     
    Juan T. Llibre, Apr 30, 2007
    #2
    1. Advertising

  3. Brian Cryer

    Brian Cryer Guest

    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.


    "Juan T. Llibre" <> wrote in message
    news:...
    > 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/
    > ===================================
    > "Brian Cryer" <brianc@127.0.0.1.activesol.co.uk> wrote in message
    > news:eKNYR%...
    >> 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.
    >> --
    >> Brian Cryer
    >> www.cryer.co.uk/brian
     
    Brian Cryer, Apr 30, 2007
    #3
  4. google:

    debug.assert asp.net


    "Brian Cryer" <brianc@127.0.0.1.activesol.co.uk> wrote in message news:eKNYR%...
    > 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.
    > --
    > Brian Cryer
    > www.cryer.co.uk/brian
    >
    >
     
    Jon Paal [MSMD], Apr 30, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Newby
    Replies:
    1
    Views:
    1,705
  2. Robert Brewer
    Replies:
    1
    Views:
    491
    bsmith
    Nov 7, 2004
  3. Thomas Guettler

    assert 0, "foo" vs. assert(0, "foo")

    Thomas Guettler, Feb 23, 2005, in forum: Python
    Replies:
    3
    Views:
    2,526
    Carl Banks
    Feb 23, 2005
  4. Alex Vinokur

    assert(x) and '#define ASSERT(x) assert(x)'

    Alex Vinokur, Nov 25, 2004, in forum: C Programming
    Replies:
    5
    Views:
    918
    Keith Thompson
    Nov 25, 2004
  5. ImpalerCore

    To assert or not to assert...

    ImpalerCore, Apr 27, 2010, in forum: C Programming
    Replies:
    79
    Views:
    1,671
    Richard Bos
    May 17, 2010
Loading...

Share This Page