C# – “Cannot evaluate expression because the code of the current method is optimized” in Visual Studio 2010

cvisual studiovisual studio 2010

I am using Visual Studio 2010 in debug mode and I have "optimize code" unchecked. I can't quick watch (or hover on) any variable in the debugger. I get this error "Cannot evaluate expression because the code of the current method is optimized".

Even a line like: int i = -3, doing a quick watch on i, I get "Cannot obtain value of local or argument 'i' as it is not available at this instruction pointer, possibly because it has been optimized away."

This link referenced in a similar question doesn't seem to apply.

Is there a setting I am missing?

Best Answer

While the project was in debug mode, the solution was not. When I changed it, it worked.