Debugging all events in Visual Studio 2010 without setting break points

前端 未结 9 654
情书的邮戳
情书的邮戳 2020-12-14 01:13

I am trying to debug a windows form application which has a large number of events: button presses, timers, etc..

Is there a way to catch every line of code being ex

相关标签:
9条回答
  • 2020-12-14 01:54

    Why would you want to break on every line? This would be very onerous and time consuming. If you want to see the activity of your program as it executes, use a logging mechanism or Debug.Writeline to output information to the Immediate window.

    0 讨论(0)
  • 2020-12-14 01:57

    For debugging a button click without setting breakpoints:

    1. Start the app with the debugger.
    2. Get to the state immediately before the intended click.
    3. Go back to the debugger and press Pause then F11 (Step Into) -- nothing will happen.
    4. Go to the app and press the button -- the debugger should take over and drop you into the event handler.

    Note: This will not work if Paint, any Mouse event, or probably some other events are handled. The debugger will drop you into those handlers any time you attempt the steps above.

    0 讨论(0)
  • 2020-12-14 01:57

    Not really, but you can set one breakpoint and single-step (F10/F11) through the rest of the code.

    0 讨论(0)
  • 2020-12-14 01:59

    Nope 'fraid not - you need to set each breakpoint yourself.

    If it helps F9 is the shortcut key for assigning a breakpoint - just set a breakpoint on the start of each method and use step through (F10) / step into (F11) from there.

    0 讨论(0)
  • 2020-12-14 02:02

    You cannot trace lines of code, but you can use Trace.TraceInformation calls where you want to have an idea of what's executed. There's also Debug.Write. Both output will write in the output window of Visual Studio.

    Another solution would be to add logging to your application, for example with log4net, but that may be overkill for your needs.

    0 讨论(0)
  • This isn't exactly what you're asking for, but in case you didn't know you can toggle an existing breakpoint on or off. In your case, you could add break points at key places throughout your code and just disable them when you don't want to debug them. That way, you'll be able to re-enable them later when you want to use them again.

    Enabling/disabling is available through the Breakpoints window found under the Debug > Windows > Breakpoints menu (CTRL+D, B). You can also include "Function" and "File" columns in the window, which might help you identify which breakpoints are in the event handlers that you care about

    0 讨论(0)
提交回复
热议问题