Solved

How do I view the code execution path in visual studio debugger (Maybe the stack trace)

Posted on 2014-10-22
4
633 Views
Last Modified: 2014-10-23
Hello, I am tracing through a huge C# code file using the VIsual Studio 2010 debugger. The file has huge methods and many "if then" statements.
Is their a way to view a list of the line numbers of the code that has been previously executed up to the point where my trace point is in the compiler? I need to know how to do that.
0
Comment
Question by:brgdotnet
  • 2
4 Comments
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 230 total points
ID: 40397032
Hi brgdotnet;

Using InteliTrace, "starting with Visual Studio 2010 Ultimate" please see this link Debugging Applications with IntelliTrace.

You can also use the Call Stack which will also give the information, How to: Use the Call Stack Window.
0
 
LVL 40

Assisted Solution

by:Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger) earned 270 total points
ID: 40398169
Visual Studio Ultimate is expensive, and the Call Stack list the method calls, not the individual lines.

The easiest way I know of with one of the regular versions of Visual Studio is to put pertinent Debug.WriteLine calls in your code. These instructions send the information you pass as a parameter to the Output window. You can leave them in your code, by default they have no impact on the release version.

Could be as simple as:

Debug.WriteLine("Start");
// Code, one or more line depending on the granularity you need.
Debug.WriteLine("1a");
// Code
Debug.WriteLine("1b");
// Code
Debug.WriteLine("2");
// Code
Debug.WriteLine("3a");
// Code
Debug.WriteLine("3b");
// Code
Debug.WriteLine("End of operations");

You can also use the Debug.Indent() method to minimally format the output.
0
 
LVL 2

Author Comment

by:brgdotnet
ID: 40399923
Thanks Guys. Just thought I would ask Jacques, isn't Debug.Writeline only used for Console applications?
0
 
LVL 40

Assisted Solution

by:Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger) earned 270 total points
ID: 40400134
No, you can use it with almost any type of project. For most of them, the result goes to the Output window, that is available by default in the lower right corner of the VS screen. You can activate it through the Debug menu if it is not there.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Connecting database in Xamarin? 6 52
Runtime Error 2 28
Error on Add method 1 38
Exit the loop 4 37
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now