Debugger does not recognize variable for return value of awaited method

我怕爱的太早我们不能终老 提交于 2019-12-10 20:41:39

问题


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

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.

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.


回答1:


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.



来源:https://stackoverflow.com/questions/12656978/debugger-does-not-recognize-variable-for-return-value-of-awaited-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!