views:

65

answers:

2

I am encountering this problem [see title] when debugging a unit test in Visual Studio 2010.

In the Locals menu, the error: "The value of the local or argument 'x' is unobtainable at this time." appears in the Value column of all my List<T> variables.

Both my unit test project and the project being tested have the "build output debug info" attribute set to full.

How do I "watch" these variables?

A: 

Since it is a local variable, the error probably means that you are not actually debugging that particular method at that time. Hence the debugger can't see the varaible.

I'm gonna guess that you created some object (apparently a List<>) as a local varaible to your unit test method, and then called the method you actually want to test. As you step through that method, you want to see the local variable.

Presumably, you've passed it to the method under test as a parameter. If so, watch the parameter. If not, then you can't affect that varaiable, so you can assume it hasn't changed.

James Curran
The variables I am referencing are in scope and are local to the current method at the time of the error.
Danny Dean
The message says it isn't. Use Debug + Windows + Threads if necessary.
Hans Passant
The message has nothing to do with scope or locality, it has everything to do with Visual Studio deciding to optimize my debugging experience by disallowing the evaluation of any List<T>.
Danny Dean
A: 

Try changing the project's target framework. I got the error with a .net4 project referencing a .net3.5 project. Changing the .net4 to .net3.5 got rid of the message.

Bruno Martinez