I have never seen this before and have no idea what it causing it.
When I put a breakpoint at the end of code below, the elapsedSeconds variable is NOT listed in the locals window. If I try to Watch it, the Value = "The name 'elapsedSeconds' does not exist in the current context". How is that possible???
public ActionResult Index()
{
Stopwatch sw = Stopwatch.StartNew();
var userID = WebSecurity.GetUserId(User.Identity.Name);
var model = ModelHelper.GetModel(userID);
long elapsedSeconds = 0;
elapsedSeconds = sw.ElapsedMilliseconds;
return View(model);
}
To open the Locals window, while debugging, select Debug > Windows > Locals, or press Alt+4. This topic applies to Visual Studio on Windows.
To view the variable's value, simply type its name into the immediate window and press Enter. The value, "Hello world" will be displayed beneath the typed line, as in the image above. To access properties of a variable or value, use the member access operator (.) as you would within source code.
Display a data tipSet a breakpoint in your code, and start debugging by pressing F5 or selecting Debug > Start Debugging. When paused at the breakpoint, hover over any variable in the current scope. A data tip appears, showing the name and current value of the variable.
Select 'Code Optimization' property as "Disabled" in Project property window, in case you want to take a look at the value. It's the compiler optimization process, that renders evaluating that variable unnecessary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With