【发布时间】:2019-06-28 19:56:16
【问题描述】:
我是新手,所以请多多包涵。我正在调试并遇到问题:
var response = await client.GetAsync(uri);
我已编辑问题,使其符合最小、完整和可验证的示例。
我在这条语句上跳过调试器以便移动到下一条语句,但由于我仍然不知道的原因,调试器似乎丢失并且无法恢复。
每次我拨打await 电话并跳过时,每次都会发生这种情况。调试器断点就消失了。
以下是全部代码:
public class App : Application // superclass new in 1.3
{
public App ()
{
MainPage = new PinPage { Title = "Pins", Icon = "marker.png" };
}
}
public class PinPage : ContentPage
{
private async Task FetchDataAsync()
{
HttpClient client = new HttpClient();
string resultUrl = "http://myuser.gtempurl.com/Service1.svc/GetLocations";
var uri = new Uri(string.Format(resultUrl, string.Empty));
var response = await client.GetAsync(uri);
if (response.IsSuccessStatusCode)
{
string content = await response.Content.ReadAsStringAsync();
var obj = JsonConvert.DeserializeObject(content);
}
}
public PinPage ()
{
FetchDataAsync().GetAwaiter().GetResult();
}
}
WCF 服务不是问题。它在公共服务器上发布,因此始终可用。我从浏览器调用它,它返回预期的字符串。
我正在使用 VS2017,它在 Android 模拟器中进行调试。
这是断点命中语句时的屏幕截图:
【问题讨论】:
-
如果您能提供minimal reproducible example,包括如何调用
FetchDataAsync,那就太好了。 -
您可能会找到感兴趣的stackoverflow.com/questions/39007006/…。
标签: c# visual-studio-2017 visual-studio-debugging