Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Watch window stopped accepting some usings

I am using the debugger to step through my code. The code file I’m in has usings at the top, including for example

using System.Linq;

In Visual Studio 2008 this used to apply to the Watch window while debugging, so I could use extension methods such as .First() and .ToArray() in the watch window.

For some reason, this has stopped working in Visual Studio 2010. And it’s not just extension methods; I now have to qualify every type with the full namespace, which is really annoying.

What’s even weirder is that the IntelliSense inside the Watch window acts as if the usings were present. In other words, it does list .ToArray() for example. But then the Watch window displays the error message

'<type>' does not contain a definition for 'ToArray' and no extension method 'ToArray' accepting a first argument of type '<type>' could be found (are you missing a using directive or an assembly reference?)

So now I always have to type the really long and annoying

System.Linq.Enumerable.ToArray(blah)

How do I fix this?

like image 916
Timwi Avatar asked Nov 05 '22 10:11

Timwi


1 Answers

Try again, without Attaching to Process (rather, clicking F5), and making sure the checkbox "Enable the VIsual Studio hosting process" (right click on project->Properties->Debug) is checked.

For an explanation on why this appears to sometime work and sometimes not, and why the suggestion I gave might help, see JaredPar's blog post on the subject.

like image 94
Omer Raviv Avatar answered Nov 14 '22 23:11

Omer Raviv