[英]Visual Studio Watch window not taking into account usings
I have the following code in a view model: 我在视图模型中有以下代码:
public Point Location
{
get
{
var rangePixels = Range * PixelsPerMile;
var xCoordinate = OwnLocation.X * MapScale + rangePixels * Math.Cos(Theta);
var yCoordinate = OwnLocation.Y * MapScale - rangePixels * Math.Sin(Theta);
return new Point(xCoordinate, yCoordinate);
}
}
One of the usings at the top of the code file is System
, which contains Math
. 代码文件顶部的一个用法是
System
,它包含Math
。
If I view Math.Sin(Theta)
in the Watch window (by selecting the code, right clicking, and choosing "Add Watch"), I get the following error: 如果我在Watch窗口中查看
Math.Sin(Theta)
(通过选择代码,右键单击并选择“Add Watch”),我收到以下错误:
The name 'Math' does not exist in the current context
当前上下文中不存在名称“Math”
What I want to know is: 我想知道的是:
I should note this question is vaguely similar to this , but I'm not having any issues mousing over my local variables, and I'm not using PostSharp. 我应该注意到这个问题与此类似,但我没有任何问题将鼠标置于我的局部变量上,而且我没有使用PostSharp。
Edit 编辑
I just tried resetting all my Visual Studio settings backs to default, and I'm still getting the same error. 我只是尝试将我的所有Visual Studio设置重置为默认值,但我仍然遇到同样的错误。 If someone wants to try a simple test in Visual Studio, I just want to know if you get an error if you add a watch for
Math.Sin(1)
. 如果有人想在Visual Studio中尝试一个简单的测试,我只想知道如果你为
Math.Sin(1)
添加一个手表就会出现错误。
Edit 2 编辑2
Here are a couple screen captures to show what I'm experiencing: 这里有几个屏幕截图,以显示我正在经历的:
Edit 3 编辑3
Interestingly, intellisense works if I type Math.
有趣的是,如果我输入
Math.
,intellisense就有效Math.
into the Watch window, but if I complete the expression, I still get the error: 进入Watch窗口,但如果我完成表达式,我仍然会收到错误:
Edit 4 编辑4
To address BACON's questions: 解决BACON的问题:
It appears that the culprit is a third-party library that performs IL weaving (Fody.PropertyChanged). 罪魁祸首似乎是执行IL编织的第三方库(Fody.PropertyChanged)。
If I create a new WPF project without this library, I'm able to use Math.Sin()
in the Watch window. 如果我创建一个没有这个库的新WPF项目,我可以在Watch窗口中使用
Math.Sin()
。 Once I install PropertyChanged
, I start getting the "not available in this context" error. 安装
PropertyChanged
,我开始收到“在此上下文中不可用”错误。
Thanks to @BACON for leading me down the right path to figuring this out. 感谢@BACON引导我走上正确的道路来解决这个问题。
Here's a link to an issue I posted on the PropertyChanged site: 这是我在PropertyChanged网站上发布的问题的链接:
http://code.google.com/p/propertychanged/issues/detail?id=6&thanks=6&ts=1330494634 http://code.google.com/p/propertychanged/issues/detail?id=6&thanks=6&ts=1330494634
Edit 编辑
And subsequently, it turns out this is probably a bug in Mono-Cecil, which PropertyChanged uses: 随后,事实证明这可能是Mono-Cecil中的一个错误,PropertyChanged使用它:
https://github.com/jbevain/cecil/issues/90 https://github.com/jbevain/cecil/issues/90
I did this in a litte test app, in the constructor.. 我是在一个litte测试应用程序中,在构造函数中完成的。
Trying to put a watch on Math lets me see the values of E and PI. 试着把手表放在数学上可以让我看到E和PI的值。 You cannot put one on Sin.
你不能把一个放在罪上。 Putting one on val works just fine.
把一个放在val上就可以了。
So, no, I don't think that it's quite normal, unless you clicked on the wrong name. 所以,不,我不认为这是正常的,除非你点击了错误的名字。 Ie, not the variable, but the "Sin" portion...
即,不是变量,而是“罪”部分......
Here is where I highlighted the entire thing... 这是我突出整个事情的地方......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.