Is there any way to break on the next line of code executed in Visual Studio?

前端 未结 5 1225
不思量自难忘°
不思量自难忘° 2021-01-07 16:34

I\'m trying to track down a bug that occurs when I click a particular element on an aspx page...

In the past I\'ve had to track down the class that handles that part

相关标签:
5条回答
  • 2021-01-07 16:53

    Have you tried the Debug > Break All ("pause") button? (Ctrl+Break)

    Debug > Break All

    It'll usually break somewhere pretty low on the stack, like at Show() for your main form in a WinForms app, but if you then Step Into to get past that, it'll often work pretty well for this sort of thing.

    0 讨论(0)
  • 2021-01-07 16:53

    Debug -> Exceptions

    Check thrown for the CLR Exceptions.

    EDIT

    The odds are you are having a CLR exception. Using this method the debugger will always break when an exception occurs. This is very convenient compared to reading the stack trace.

    0 讨论(0)
  • 2021-01-07 16:59

    Are you looking for the Step Into (F11) or Step Over (F10) ?

    -- Edit

    Do you also know about the Call Stack window? It can help you determine your location, and what is happening.

    0 讨论(0)
  • 2021-01-07 17:03

    Conditional Breakpoints may be your answer. You can set them were you think your code is breaking and they will only halt when the condition is satisfied.

    0 讨论(0)
  • 2021-01-07 17:06

    Some ideas:

    • If you use a consistent naming convention for your event handlers then it should be trivial to do a global search for them all and add breakpoints. You can quickly record a macro on the first hit and then play back the macro to take all the pain out of repeating the operation many times. With a bit of practice you'll be able to breakpoint all the handlers in a few seconds flat.

    • Add an extra event handler for the event (create it early - e.g. in the constructor - so it's added before all other event handlers that your app adds, and is therefore hopefully called first) and stick a breakpoint in it. Once you've hit the breakpoint you can then single step through the other event handlers on the event.

    • write a custom event handler that handles the click and simply generates a new event. Attach all your other event handlers to this secondary event. Then you can breakpoint the first handler and step through the secondary handlers that it calls.

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