c# - 监 window 口中的 $ReturnValue 在 VS2015 中不起作用

标签 c# visual-studio-2015 watch

在 VS2013 中,我们可以通过检查名为 $ReturnValue 的 Watch 窗口条目来查看方法的返回值。 .这在 VS2015 中似乎不起作用。

例如我制作了一个新的控制台应用程序,其中包含以下代码:

using System;

namespace ReturnInspector
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Number: {0}", Method1());
        }

        public static int Method1()
        {
            return Method2(1000);          //A
        }                                  //B

        private static int Method2(int i)
        {
            return i + 42;
        }
    }
}

如果我在 //A 行放置一个断点, 然后一旦它中断,F10 跳到行 //B , $ReturnValue Watch 窗口中的项目在 VS2013 中显示为“1042”,但在 VS2015 中显示为:

error CS0103: The name '$ReturnValue' does not exist in the current context

请注意,Autos 和 Locals 窗口正确显示为:

ReturnInspector.Program.Method2 returned    1042

有谁知道$ReturnValue在 VS2015 中删除了监 window 口功能?

最佳答案

确保您已在工具 >> 选项 >> 调试 >> 使用旧版 C# 和 VB 表达式求值器 选项中选中。

来自 MSDN :

You must have the legacy expression evaluators turned on for $ReturnValue to be recognized (Tools / Options / Debugging / Use the legacy C# and VB expression evaluators). Otherwise, you can use $ReturnValue1.

关于c# - 监 window 口中的 $ReturnValue 在 VS2015 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34858415/

相关文章:

c# - 如何在SpreadsheetGear中通过文本查找ColumnPostion?

c# - 在我的 asp.net mvc 2 应用程序中,为什么有时会丢失通过 RedirectToAction 传递的参数?

visual-studio-2015 - IIS Express Web服务器端口正在使用中

c++ - 在VS 2015中使用Microchip的mpusbapi.h会产生“LNK2005已定义”错误

java - Hadoop build Failing in Windows : zconf. h 从 native.sln 中丢失?

javascript - `gatsby develop` 每次更改博客条目时都会崩溃

c# - 根据 future 日期自动删除 Azure 中的 Blob 文件

c# - 错误操作编辑 Controller MVC

angularjs - 带有下划线或驼峰大小写的 Angular $watch 变量名称不会更新

c++ - 如何在 Eclipse 中查看 std::map 的内容?