Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 particular event and put a break point on the line that I think should be hit. Often it takes me several tries before I finally find the correct class....especially if the class is a user control buried somewhere...

So it's left me wondering if there is any way to get Visual Studio to break at the next line of code executed after I click an element (say a button) on an aspx page. I know there is a way to break on any exception that is thrown so I'm thinking maybe there is something similar that could help me.

If this sort of feature isn't a possibility, perhaps someone could suggest a better way for me to quickly find the class I want to debug...

like image 508
mezoid Avatar asked Sep 02 '09 03:09

mezoid


People also ask

How do you break a code in Visual Studio?

Click in the left margin at the line you want to break at (or press F9).

How do you add a break point in VS code?

An inline breakpoint can be set using Shift+F9 or through the context menu during a debug session. Inline breakpoints are shown inline in the editor. Inline breakpoints can also have conditions. Editing multiple breakpoints on a line is possible through the context menu in the editor's left margin.

How do I skip a line in Visual Studio?

The "Set Next Statement" (CTRL+SHIFT+F10) shortcut will work at the end of a function... but you need to use the mouse though as well. On VS 2019 there are those green arrows in front of lines, hold CTRL key and you can set next statement directly there, skipping anything in between.


3 Answers

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.

like image 131
Ryan Lundy Avatar answered Oct 17 '22 21:10

Ryan Lundy


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.

like image 25
Noon Silk Avatar answered Oct 17 '22 22:10

Noon Silk


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.

like image 2
scottm Avatar answered Oct 17 '22 20:10

scottm