Visual Studio Watch window does not consider usage

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 headers at the top of the code file is the System , which contains Math .

If I look at Math.Sin(Theta) in the Watch window (by selecting the code, right-clicking and selecting "Add Watch"), I get the following error:

The name "Math" does not exist in the current context

What I want to know:

  • Is this the expected / standard behavior for Visual Studio 2010? I could have sworn that this was never a problem, but perhaps it always worked like that, and for some reason I did not notice.
  • If it is not normal to get this error, any thoughts on what could be the problem? Visual Studio has a million settings, and I don't know where to start.

I should note that this question is vaguely similar to this one , but I have no problems with my local variables and I am not using PostSharp.

Edit

I just tried resetting all my Visual Studio settings to the default, and I still get the same error. If someone wants to try a simple test in Visual Studio, I just want to know if you get an error message if you add a clock for Math.Sin(1) .

Edit 2

Here are some screenshots to show what I'm experiencing:

Adding Math.Sin (1) to watch

Showing error for Watch

Edit 3

Interestingly, intellisense works if I type Math. in the Watch window, but if I complete the expression, I still get the error:

Showing intellisense working

Change 4

To ask BACON questions:

  • I get the same behavior with QuickWatch and Immediate.
  • Closing and reopening all windows does not solve the problem.
  • I am using Visual Studio 2010 Professional (version 10.0.40219.1 SP1Rel)
  • I tried targeting the .NET 4.0 Client Profile and the full .NET 4.0. There was no difference. I created a console application (and not a WPF application) focused on the .NET 4.0 client profile, and finally an error did not occur. Thus, WPF can be a problem (or WPF with some third-party libraries). (Will be checked for the following.)
+8
debugging c # visual-studio visual-studio-2010 mono.cecil
source share
2 answers

It seems that the culprit is a third-party library that performs the IL plexus (Fody.PropertyChanged).

If I create a new WPF project without this library, I can use Math.Sin() in the viewport. As soon as I install PropertyChanged , I begin to get a "inaccessible in this context" error.

Thanks to @BACON for taking me the right way to figure this out.

Here's a link to the question I posted on PropertyChanged:

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 in which PropertyChanged uses:

https://github.com/jbevain/cecil/issues/90

+6
source share

I did this in a litte test application, in the constructor.

enter image description here

Trying to put the clock on Math allows me to see the values ​​of E and PI. You cannot put it in Sin. Putting one on the shaft is just fine.

So no, I don’t think it’s completely normal if you don’t click on the wrong name. Ie, not a variable, but part of the "Sin" ...

That's where I highlighted the whole thing ...

enter image description here

+1
source share

All Articles