Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I've had this thing that keeps bugging me in some parts of code and I have no idea what's causing it.

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

Whereas some variables, I can't view the contents, nothing appears.

Also, if I try investigating those I can't through the immediate window, it tells me The name 'temp' does not exist in the current context

I'm really annoyed at just WHY this would be happening, some integers but not others, some class objects but not others of the same type.

Closing Visual Studio and restarting doesn't fix it.

I'm running in Debug with no optimization.

Just looking for some help with this issue so thanks in advance.

Here is an example of the code where it occurs, no special code or delegates. It can also happen in random parts of the program even if there are only a few 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
}

like image 981
Craig White Avatar asked Feb 05 '13 04:02

Craig White


People also ask

How do I show Immediate windows in VS?

To display the Immediate window, open a project for editing, and then choose Debug > Windows > Immediate or press Ctrl+Alt+I. You can also enter Debug. Immediate in the Command window. The Immediate window supports IntelliSense.

What is Immediate window in VB?

The Immediate window displays information resulting from debugging statements in your code or from commands typed directly into the window. To display the Immediate window. From the View menu, choose Immediate window (CTRL+G).

Is not a known variable in the current context?

It means that the code you have executed so far has not defined the variable yet. Press F7 a couple more times until the code defining the variable is executed.

Does not exist in the current context c# asp net?

Many a times while writing a code we get this error which says, “The name does not exists in the current context”. This is because the code behind file is not able to find the control being added to your aspx file.


1 Answers

Also, if I try investigating those I can't through the immediate window, it tells me The name 'temp' does not exist in the current context

try to use the full name of the method

for example:

namespace.class.method();

instead of

class.method();

it also seems that the immediate window has a dependency to the current selected file/project.

hope this helps Mathias

like image 126
Mat Avatar answered Sep 28 '22 12:09

Mat