Solved

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

Posted on 2011-02-15
6
608 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 74

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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 74

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 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