Visual Studio 2012 - 本地窗口中缺少变量 [英] Visual Studio 2012 - Variable missing from Locals Window

查看:110
本文介绍了Visual Studio 2012 - 本地窗口中缺少变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前从来没有看到过,不知道是什么导致的。

I have never seen this before and have no idea what it causing it.

当我在下面的代码末尾放置一个断点时,elapsedSeconds变量不是列在当地人的窗口。如果我尝试观看它,Value =名称elapsedSeconds在当前上下文中不存在。如何可能?

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);
}


推荐答案

选择代码优化属性在项目属性窗口中显示为已禁用,以备您查看该值。这是编译器优化过程,它可以使不必要的变量进行评估。

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.

这篇关于Visual Studio 2012 - 本地窗口中缺少变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆