Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find a method caller when stepping through C# in Visual Studio 2008?

If I set a breakpoint on a method, how can I see what called the method, when the breakpoint is hit in Visual Studio 2008?

like image 589
Ronnie Overby Avatar asked Aug 05 '09 21:08

Ronnie Overby


People also ask

How can I get call stack information?

View the call stack while in the debugger While debugging, in the Debug menu, select Windows > Call Stack or press ctrl + alt + C .

How can I see the call stack code in Visual Studio?

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".

Where is a method called in Visual Studio?

To display the Call Hierarchy window, right-click in the code editor on the name of a method, property, or constructor call, and then select View Call Hierarchy.


2 Answers

Check the Call Stack window (from the menu: Debug > Windows > Call Stack). Double clicking each entry there will take you to the calling statement. You can also right click on it to enable/disable showing external code items and calls from other threads.

like image 199
mmx Avatar answered Oct 14 '22 23:10

mmx


When the breakpoint is hit, you can view the entire call stack. You can bring that window up by going through the Debug menu->Windows->Call Stack.

You can also bring it up by the shortcut Alt+Ctrl+C

EDIT: You can also right-click on a function name, and view the "Callers Graph", which will show you all the callers for your method. Alternatively, you can bring the Call Browser (by going to View->Other windows->Call Browser ) and search for your method's name.

like image 27
Umair Avatar answered Oct 14 '22 23:10

Umair