Solved

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

Posted on 2011-02-15
6
615 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

751 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