Andrew Thomas




Blog Post

Debugging Tools in Visual Studio

Nov 14, 2020 Visual Studio

When training young developers or those who are not used to using advanced development environment I am always surprised at how little they use extremely useful features of debugging. I thought it would be good to highlight some of the useful tools found in Visual Studio and most proper debuggers.

Call Stack

The call stack shows the code path from the outer most stack right through to where the breakpoint is. It shows you information such as the calling in parameters and the method that called the method the breakpoint is in. Double-clicking the lines below the breakpoint line will take you to that section of code. For example in the below screenshot we can see that the btnLogin_Click() calls MasterPages.DoLogin() which calls Security.DoLogin() which calls the method the breakpoint is in Person.GetPerson(). This is very useful for seeing the stack trace.


The locals tab shows all local variables for the current method that the breakpoint is at. You can change and of the values if you want to test different outcomes by selecting the value and editing it.


The watches tab is similar to local tab above except that you can add your on variables to look at (including Request and Response objects if available) and even do equality tests. You can change and of the values if you want to test different outcomes by selecting the value and editing it.

Immediate Window

The immediate window is a free form expression evaluator that allows you to evaluate variables/expression, execute statements and a whole range of other tasks. It is very useful for testing out code and is worthwhile experimenting with.

The final point of debugging discussion is the use options when stepping through code: “Step Into”, “Step Over” and “Step Out”.

• F11 — Step Into — Steps into the current line of code i.e. if the breakpoint is currently on a method called DoLogin() and you step into it, it will go to the DoLogin() method. However if any of the parameters that are passed into DoLogin() call methods aswell it will step into them first. • F10 — Step Over — Steps over the current line of code and goes to the next line of code — it does execute the code but doesn’t step into the method. • Shift F11 — Step Out — Steps out of the current method and returns to the method that called the method you were in (it does execute the rest of the code). i.e. If DoLogin() calls GetPerson() and the breakpoint is on any line in the GetPerson() method and you step out then you the breakpoint will move to the GetPerson() method call of the DoLogin() method.