Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why would Visual Studio 2010 say it can't show a variable during debug?

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 http://www.deviantsart.com/upload/jcnr1s.png

like image 463
Edward Tanguay Avatar asked May 06 '10 21:05

Edward Tanguay


2 Answers

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?

like image 171
Zach Bonham Avatar answered Oct 19 '22 23:10

Zach Bonham


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

like image 40
Chris Avatar answered Oct 19 '22 23:10

Chris