Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-02-15
6
Medium Priority
?
617 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
Technology Partners: 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 1000 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 1000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

715 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