views:

59

answers:

2

In Visual Studio 2010 sometimes when I want to get the value of a variable while debugging, it tells me that it "does not exist in this context" when it obviously does.

I have found that if I use the variable, as in the screenshot below, then it is able to show it.

Has anyone experienced this? Visual Studio 2008 never did this.

How can I get Visual Studio 2010 to always show me variable values while debugging?

alt text

+3  A: 

Hazarding a guess..

Could it be that your running in Release mode and the variable has been optimized out? Once you actually use the value, then it no longer can optimize the value out?

Zach Bonham
Can you even use the debugger in Release mode?
Chris
you bet! Change your build configuration to 'Release' and hit F5 - should still run, though YMMV with optimizations enabled. I'm only guessing thats what might be whats seen here.
Zach Bonham
Far out... your idea seems pretty likely then.
Chris
that was it, I didn't know you could debug in release mode so it didn't occur to me, thanks!
Edward Tanguay
A: 

Is GetListOfFileNames() deferring execution? Try tacking .ToList() on it.

Chris