Solved

How to trace value of local variables during a session of activities

Posted on 2011-02-15
6
609 Views
Last Modified: 2012-05-11
Hey !

I have a pretty complex project to work on. It is a web application in Asp.net and C#. I want to track values of local variables in aspx, ascx, global.asax, and .cs files of the solution. I know it would'nt be possible to track values in some files directly but I am sure there must be some way around. I am open to put the values in text file or excel sheet. or if there is any other simple way.

Additionally, I am using Visual Studio Ultimate edition. So please let me know if there is any built-in functionality to do this. Thanks,

0
Comment
Question by:pratz09
6 Comments
 
LVL 9

Expert Comment

by:gdupadhyay
ID: 34901788
The scope of local variable is limited upto the function/ method or class.You can't track all at one time.
Track by using break point or immediate window.

Let me know for any question.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 34901802
Are you familiar with the "Watch" and "Locals" windows? You should be able to inspect the value of session variables via the Watch window. phoffric has a nice article pertaining to debugging in Visual Studio 2008 (and C++), but most of the concepts are still applicable in VS 2010.

http://www.experts-exchange.com/Programming/Languages/CPP/A_2688-Microsoft-Visual-Studio-2008-Express-C-Quick-and-Dirty-Debugger-Tutorial.html
0
 

Author Comment

by:pratz09
ID: 34901892
Hmm.. That was useful, definite bookmark. But I here I am not using session state. I am doing little computing on some pages, and storing some local variables/ helper variables. What do you guys (experts) use to check if correct value is passing through the code ? Even if I debug (F10), I can't really see the "value" of that variable at that particular moment, Can I ?

One option could have been enabling trace, but it doesn't give much information about the value of those variables.

Is it possible to put hidden message box / controls, and while running in debug mode, I can display the value of that local variable.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 250 total points
ID: 34903733
If you are debugging a web site in debug mode, then yes, you can see the live variables. Even if you wanted to debug the live site, you could do the same thing (I wouldn't suggest doing it on production). You can use the "Attach to Process" feature found under the Tools menu. You would attach to the "w3p.exe" process (basically, IIS). The caveat is that you have to have the .pdb files (debugging sybmols) in the same directory as your DLLs and assemblies. There is also a remote debugging feature, but it is sometimes a pain to set up.
0
 
LVL 3

Assisted Solution

by:chandra_darbha
chandra_darbha earned 250 total points
ID: 34904064
If you want to track these values during a live request and not a debug session, you can add System.Diagnostics.Trace.WriteLine("value of the variable"); statements wherever you want to track.

These statements will result in trace events at the OS level and can be viewed using DbgView (Debug View) which is part of the Sysinternals suite (http://technet.microsoft.com/en-us/sysinternals/bb842062).

Thanks,
Chandra
0
 
LVL 3

Expert Comment

by:chandra_darbha
ID: 34904068
If you want to see these statements only in the Debug mode and not in the release version of the code, you can use System.Diagnostics.Debug.WriteLine instead of Trace.WriteLine.

The Debug.WriteLine statements will be removed by the compiler during Release build.

Thanks,
Chandra
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 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

11 Experts available now in Live!

Get 1:1 Help Now