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.
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.