Solved

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

Posted on 2011-02-15
6
616 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

636 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