监视窗口停止接受某些使用
我正在使用调试器来单步调试我的代码。我所在的代码文件在顶部有使用,例如
using System.Linq;
在 Visual Studio 2008 中,这用于在调试时应用于“监视”窗口,因此我可以使用扩展方法,例如 .First()
和监视窗口中的 .ToArray()
。
由于某种原因,这在 Visual Studio 2010 中已停止工作。这不仅仅是扩展方法;它还包括扩展方法。我现在必须使用完整的命名空间来限定每种类型,这真的很烦人。
更奇怪的是,Watch 窗口内的 IntelliSense 的行为就好像使用存在一样。换句话说,它确实列出了.ToArray()
。但随后 Watch 窗口显示错误消息
'<类型>'不包含“ToArray”的定义,并且没有扩展方法“ToArray”接受类型“
”的第一个参数可以找到(您是否缺少 using 指令或程序集引用?)
所以现在我总是必须输入非常长且烦人的内容
System.Linq.Enumerable.ToArray(blah)
如何解决这个问题?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
再试一次,不要附加到进程(而是单击 F5),并确保选中“启用 VIsual Studio 托管进程”复选框(右键单击项目 -> 属性 -> 调试)。
有关为什么这有时有效有时无效以及为什么我给出的建议可能有帮助的解释,请参阅 JaredPar 关于该主题的博客文章。
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 many bugs, it disappeared and I have no idea why. :(