调试器无法识别等待方法返回值的变量 [英] Debugger does not recognize variable for return value of awaited method

查看:29
本文介绍了调试器无法识别等待方法返回值的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在针对 .NET 4.5 和 Windows Store 应用程序的可移植类库中有这个非常简单的代码:

I have this very simple code in portable class library targeted to .NET 4.5 and Windows Store Apps:

HttpResponseMessage response = await _httpClient.PostAsync(uri, content);
response.EnsureSuccessStatusCode();

当我将断点放在第二行并运行我的应用程序时,断点正确命中,但我无法调查调试器中的响应,因为它报告:

When I put breakpoint on the second line and run my application the breakpoint is correctly hit but I cannot investigate response in the debugger because it reports:

当前上下文中不存在名称响应"

The name 'response' does not exist in the current context

我不确定它有多少相关性,但我还必须在调试器的设置中禁用 Just My Code 调试器设置,以便能够调试放置在与执行应用程序.

I'm not sure how much is it related but I also had to disable Just My Code debugger setting in Debugger's settings to be able to debug my portable class library placed in the same solution as the executing application.

是 async-await 方法、可移植类库、目标应用程序(特别是 Windows Store 应用程序)或这些工具的组合的某些限制吗?或者它是一个调试器错误?任何解决方法都会很有帮助.

Is it some limitation of async-await methods, portable class libraries, targeted applications (Windows Store App particularly) or combination of those tools? Or is it a debugger bug? Any workaround would be more than helpful.

推荐答案

我不确定在较新的 Visual Studio 更新中是否还会发生这种情况(我没有那个代码库了)但我的问题可能是将 Async-Await 调试与代码契约相结合.不使用代码契约时我没有看到问题.

I'm not sure if this still happens with newer Visual Studio updates (I don't have that code base anymore) but the problem in my case was probably combining Async-Await debugging with code contracts. I haven't seen the problem when not using code contracts.

这篇关于调试器无法识别等待方法返回值的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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