Visual Studio 2015异步变量未在调试器中显示

ada*_*039 4 asp.net-mvc visual-studio-2015 asp.net-core

我有一个.NET Core ASP.NET MVC 6应用程序,我确信它是Visual Studio中的一个错误.如果我在await语句后面放置一个断点,那么该对象不会显示在Locals中,并且我无法鼠标移动来检查.但是,如果我使用变量,它仍然可以正常工作,并且它确实填充.

像这样简单:

public async Task<IActionResult> Index()
    {
        var location = await _listingLocationService.GetLocationByAddress("123 Fake Street");
        return Content(location.Latitude.ToString() + " " +location.Longitude.ToString());
    }
Run Code Online (Sandbox Code Playgroud)

如果我将断点放在return语句上,我就无法检查位置.它不会出现在任何地方.我甚至可以删除await并在结尾放置一个.Result,但仍然没有显示.但是当我继续时,视图会显示location.latitude,并且location.longitude会很好.所以我知道它正在填充.

为了完整起见,我还将包含GetLocationByAddress函数,它也会做同样的事情,如果我在等待之后的任何地方放置一个断点,我就无法检查变量(甚至是反序列化的列表!).

public async Task<Geolocation> GetLocationByAddress(string address)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("https://maps.googleapis.com/maps/api/geocode/json");
                var request = new HttpRequestMessage(HttpMethod.Get, "?address=" + WebUtility.UrlEncode(address) + "&key=...");
                var response = await client.SendAsync(request);
                var contents = await response.Content.ReadAsStringAsync();
                var locationResult = JsonConvert.DeserializeObject<GoogleLocationResult>(contents);
                if (locationResult.status == "OK")
                {
                    var result = locationResult.results.First().geometry.location;
                    return new Geolocation
                    {
                        Latitude = result.lat,
                        Longitude = result.lng
                    };
                }
                else
                {
                    return null;
                }
            }
        }
Run Code Online (Sandbox Code Playgroud)

Vi1*_*100 5

好吧,在这个问题失去了一整天之后我终于找到了问题的根源以及解决方案...在我的情况下,问题已经开始,在更新我的项目以使用.net核心1.1预览1后面的步骤此处显示:链接到MSFT .NET博客

问题是由project.json文件中的这行代码引起的:

"buildOptions": {
  "debugType": "portable",   <---- THIS
  "preserveCompilationContext": true,
  "emitEntryPoint": true
}
Run Code Online (Sandbox Code Playgroud)

在将"debugType"设置为"full"之后,等待变量在调试时再次开始显示.

希望它对某人有帮助!