VS Immediate Window - the name does not exist in the current context

I had this thing that keeps me in some parts of the code, and I have no idea what causes it.

I have a code block where I set a breakpoint. If I then use my cursor and hover over a variable, I can usually navigate through the contents and values ​​of that variable.

While some variables I cannot view the contents, nothing appears.

In addition, if I try to investigate those that I cannot perform through the nearest window, he informs me The name 'temp' does not exist in the current context

It really annoys me only WHY this will happen, some integers, but not others, some objects of the class, but not others of the same type.

Closing Visual Studio and restarting it does not fix it.

I work in Debug without optimization.

Just look for some help on this issue, so be sure to get ahead of time.

Here is an example of the code where it occurs, there is no special code or delegates. This can happen in random parts of the program, even if there are several lines of code.

segs2D = ConvertSegmentsTo3DLines(segs2D);
IList<DSegment2D> segs3D = DSegment2D.Duplicate(segs2D);
TransformSegments(segs3D, transform);
foreach (var seg in segs3D)
    MoveSegmentToSolid(seg, moveNormal, solid, false);

Dictionary<double, Strategy> strategiesDic = new Dictionary<double, Strategy>();

double d1 = (double)(segs3D[0].GetP1Tag() ?? 0);
double d2= (double)(segs3D[0].GetP2Tag() ?? 0);
foreach (DSegment2D seg in segs3D)
{
    d1= (double)(seg.GetP1Tag() ?? d1);
    d2= (double)(seg.GetP2Tag() ?? d2);
    ...Stuff
}

+5
source share
4 answers

It turns out that the only complexity of the method and the number of indentation caused the problem at that time. Since then, I have simplified and used most of the source code, and I no longer have this problem. I am also upgrading to VS2012, which may also help.

0
source

In addition, if I try to research those that I cannot perform through the nearest window, this tells me. The name "temp" does not exist in the current context

try using the fully qualified method name

eg:

namespace.class.method();

class.method();

, /.

, Mathias

+4

, , (.. ).

, , , , bar :

public class Whatever
{
    public void DoSomething()
    {
        string foo = "blah"; // Breakpoint hit and execution stopped here.

        // Do something.

        DoSomethingElse();
    }

    public void DoSomethingElse()
    {
        string bar = "yack";

        // Do something else.
    }
}
0

I had a similar problem. I thought I was in Debug, but there was another simple (but important) step. If “Solution Configuration” is set to “Debug”, I also had to click the down arrow next to “Debug” and select “Configuration Manager ...”, and then in this corresponding pop-up window “Configuration” is still set to “Release” "- I had to change this to" Debug "and click the" Close "button. Extracting from there allowed me to view all the variables during debugging.

0
source

All Articles