Sometimes when I quickwatch an expression at runtime, the Quick Watch window shows an error saying the name does not exists in the current context. The same goes for the immediate window. The expression I try to evaluate, however, is perfectly recognized by the class, without throwing any compilation error.
For example, I can have the following line of code:
double x = Math.Pow(2,3);
If I stop the cursor on this line and quickwatch the "Math.Pow(2,3)" part, it gives me an error and I need to place a "System." before my expression; as I said, the same expression runs smoothly in the code window, so I'm not sure which is the "context" the error refers to.
Could it be that these debug windows reference namespaces declared in the class but can't do the same for namespace imported by the project?
Solution:
Go to your program.cs file and add the usings you want your immediate window to use, this works for both Console and Windows Forms applications
Refrence namespaces to Immediate Window in a Class Library Project
If you are using the Immediate Window in "Design Time" mode, and want reference some namespaces to it, you need to set the ouput mode to Windows Application, and create a program that does nothing.
Program.cs
using System;
//Add all the refrences you need immediate window to use here
namespace YourNamespace
{
static class Program
{
static void Main()
{
}
}
}