Share via


Did you know… You can break the debugger without using Breakpoints? - #313

If you are using VB, you can add the keyword Stop in your code to suspend execution. The Stop statement is the equivalent to adding a breakpoint. Sometimes it is just faster to type “Stop” than it is to remember to hit F9 or reach for the mouse.

VB Stop example

If you are using C#, you can use the Debugger.Break() method in your code, provided you are using the System.Diagnostics namespace.

C# Debugger.Break() example

Technorati Tags: VS2005Tip,VS2008Tip

Comments

  • Anonymous
    September 15, 2008
    I found Debugger.Break() really helpful when I needed to debug a Windows Service application as it was starting up. Sometimes it was too late to start the service then attach the debugger.

  • Anonymous
    September 15, 2008
    You can also break with "debugger" in javascript.

  • Anonymous
    September 15, 2008
    The comment has been removed

  • Anonymous
    September 16, 2008
    Easier than pressing F9 ??? Give me a break! This is ugly and messy.

  • Anonymous
    September 19, 2008
    The comment has been removed

  • Anonymous
    September 19, 2008
    Another great one is Debugger.Attach(). This is useful when you are working on managed code hosted in an unmanaged application. Instead of doing the whole "Attach to Process" it just prompts you to attach itself.

  • Anonymous
    September 29, 2008
    "Easier than pressing F9?" Sometimes the code you want to debug is launched by someone else and you can't easily launch it in the debugger yourself.  So you put that in your code and you'll be prompted to JIT debug the code.

  • Anonymous
    March 02, 2009
    本篇包括tip311-tip320http://www.watch-life.net/visual-studio/visual-studio-2008-tip-day-31.html#311、按S...