This web site uses cookies. By using the site you accept the cookie policy.This message is for compliance with the UK ICO law.

VS 2003+

Visual Studio Call Stack Window

The call stack records each member call, allowing the calling code to be resumed when a member exits. The Call Stack window is a debugging tool in Visual Studio that allows the call stack to be examined whilst a program is in debug mode.

Call Stack

All except the simplest programs include a number of types with methods and properties that can be called. When a call is made, the details of the calling member are added to a stack, so that execution can resume from the correct location when the member returns. This stack grows with every call and can become very large. When your software is complex, this can make it difficult to keep track of all of the calls that have been made whilst debugging. To help, Visual Studio includes the Call Stack window.

To display the call stack window you must first start your code in debug mode. Either start your application using the Step Into command or use a breakpoint to halt execution. You can then show the window by opening the "Debug" menu, expanding its "Windows" submenu and selecting "Call Stack". The call stack window will appear similar to the image shown below.

Visual Studio Call Stack

In the above image you can see the columns of the call stack table. The key column is labelled, "Name". It shows a list of all of the calls made to reach the current position in the source code. The latest calls are shown first and the oldest calls appear at the bottom of the list. The current member is indicated by an arrow in the leftmost column.

The Name column can include various elements of information. In the image all elements are enabled. They can be switched on and off by right-clicking the grid and choosing from the context-sensitive menu that appears. The most important elements are:

  • Module. The module is the file that the code is found within. All of the call stack elements in the image are within the executable, "ConsoleApplication1.exe".
  • Member. The fully-qualified name of the member that was called. In the image, the most recent call was to the Crm.CustomerSaver.Save method.
  • Parameters. The parameters for methods and other members can be enabled and disabled in the grid. You can choose whether to include the type names for the parameters and the values that were provided. For example, the first line in the above grid includes a parameter named "retries" that is an integer and received a value of 25.
  • Line Number. The line number for each call stack element refers to the line in the source code.

Showing External Code

You may notice that some rows in the call stack window simply show, "[External Code]". These refer to elements of code that are external to the solution. For example, if you are developing a plug-in for an application, the hidden items may be calls made within the main application. Only items within the plug-in will be shown. To view calls made from external code, right-click the grid and enable the "Show External Code" option in the context-sensitive menu.

23 January 2012