locked
How to view out-of-scope variables with debugger? RRS feed

  • Question

  • Good morning:

    Can anyone tell me the trick for viewing out-of-scope variables while debugging? I have a time-dependent application that I cannot stop by using a breakpoint (and get predictable results anyway). I could write values to the quick-console, but I don't always know what variable I want to look at in advance. Stopping the application to re-write the code often alleviates the problem that needed debugging.

    I have read several books on vb.net, and none seem to handle the subject of debugging very well, other than the use of breakpoints, and try/catch.

    As a follow up question. Any recommended reading for learning how to use the "test" functionality of .net 2005?

     

    Thanks,

    Wednesday, April 5, 2006 3:10 PM

Answers

  • Once a variable is out of scope there is no way to view its value.    Maybe this msdn magazine article on Test Driven Development is what you are looking for.


    Wednesday, April 5, 2006 6:29 PM

All replies

  • You should look into the trace.write in conjunction with traceSwitches and TraceListeners. See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdiagnosticstraceclasstopic.asp for more information.

    Jim Wooley
    http://devauthority.com/blogs/jwooley

    Wednesday, April 5, 2006 6:20 PM
  • Once a variable is out of scope there is no way to view its value.    Maybe this msdn magazine article on Test Driven Development is what you are looking for.


    Wednesday, April 5, 2006 6:29 PM
  • Jim

    Thanks - I will look into that further.

     

    Ken,

    Actually, that is the article that I read that lead me to the question. Since .net (At least the Pro version that I bought) doesn't really come with any manuals (excluding the electronic documentation), alot of what one learns comes from third party books. When I look at my toolbar in vb, I see this whole menu section under "test". After I read the article that you referenced, I started to think that one was related to the other (TDD to the "test" menu that is) and that maybe it would be a good idea to start doing things this way - but I can't seem to find much good documentation on how do use the "test" menu.

    I don't expect you to do my google searching for me - so I will leave it where it is. If you happen to know a good source of instruction for using the "test" functionallity of .net off of the top of your head, however, I would love to know.

     

    Thanks

    Thursday, April 6, 2006 7:22 PM
  • Stating that there is no way to view its value is technically true.  You are correct in that once the variable is off the stack, it's gone, but you can read it's value if you use any number of diagnostic techniques to dump the value for debugging purposes.

    You could consider using debug assertions to capture conditions that are out of normal scope for you.  You could use conditional breakpoints too -- break only if a condition is or is not met.

    Consider a blog post I put up a few days ago that provide several webcasts on debugging.  While it's not all VB.NET specific, it will give you some techniques to use in cases such as you describe.

    Friday, April 7, 2006 8:49 PM
  • Tobin,

    Thank you for the reply. I would like to read your blog but - I have a sinking feeling that I am going to feel stupid for asking this - I don't know where I can find it. Can you include a link please?

    Thanks.

    Friday, April 7, 2006 8:52 PM
  • NEVER feel stupid for asking anything -- particularly when I should have just included it to begin with! :)

    On the MSDN forums, you can usually just click on someone's name. If they have a published blog in their profile, you can view it there.  However, to get you to the post I discussed earlier and more quickly and directly, use this link:

    http://blogs.msdn.com/tobint/archive/2006/04/04/568240.aspx

     

    Friday, April 7, 2006 8:57 PM