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

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

问题描述

我在针对.NET 4.5和Windows Store Apps的可移植类库中有以下非常简单的代码:

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

我不确定它有多少关系,但我还必须在Debugger的设置中禁用 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.

异步等待方法,可移植类库,目标应用程序(尤其是Windows Store App)或这些工具的组合是否有某些限制?还是调试器错误?任何解决方法都将无济于事.

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天全站免登陆