C# 使用Newtonsoft.Json解析Json时,函数从不运行

C# 使用Newtonsoft.Json解析Json时,函数从不运行,c#,xamarin,dynamic,json.net,async-await,C#,Xamarin,Dynamic,Json.net,Async Await,我正在使用NewtonSoft.Json来解析我从一个C#网站得到的Json响应。问题是: protected async override Task<bool> DoInBackground() { var json = await GetJson(); return true; } 我做错了什么 编辑:我应该提到DoInBackground()函数在其他不使用Newtonsoft.Json的类中运行得非常好。这是我需要从服务器获取Json的第一个类 编辑:为了测

我正在使用NewtonSoft.Json来解析我从一个C#网站得到的Json响应。问题是:

protected async override Task<bool> DoInBackground() {
    var json = await GetJson();
    return true;
}
我做错了什么

编辑:我应该提到
DoInBackground()
函数在其他不使用Newtonsoft.Json的类中运行得非常好。这是我需要从服务器获取Json的第一个类

编辑:为了测试代码是否在未命中断点的情况下执行,我尝试了以下操作,但没有得到任何输出

protected async override Task<bool> DoInBackground() {
    var json = await GetJson();

    Debug.WriteLine("before");
    dynamic jsonObject = JObject.Parse(json);
    Debug.WriteLine("after");

    return true;
}
受保护的异步覆盖任务DoInBackground(){
var json=await GetJson();
Debug.WriteLine(“之前”);
动态jsonObject=JObject.Parse(json);
Debug.WriteLine(“之后”);
返回true;
}

在您的情况下,您可以简单地清除解决方案并重建它。应用程序应该运行良好,因为代码没有问题

只是VisualStudio正在使用在您对代码进行最终修改之前已经构建的应用程序


在您的情况下,可能现有的构建副本没有添加Newtonsoft.Json。

在您的情况下,您可以简单地清除解决方案并重新构建它。应用程序应该运行良好,因为代码没有问题

只是VisualStudio正在使用在您对代码进行最终修改之前已经构建的应用程序


在您的情况下,可能现有的生成副本没有添加Newtonsoft.Json。

您是否收到任何错误?@yogeshhenoy没有错误。函数根本不执行。您希望函数返回什么?现在它正在返回布尔值,您希望它返回字符串吗?然后您需要更改函数的返回类型,并从it@ChetanRanpariya返回值只是一个布尔值,指示
DoInBackground()
是否成功执行。为什么断点没有停止?@sjbhalli在调用函数之前断点是否命中?是否有错误?@yogeshshenoy没有错误。函数根本不执行。您希望函数返回什么?现在它正在返回布尔值,您希望它返回字符串吗?然后您需要更改函数的返回类型,并从it@ChetanRanpariya返回值只是一个布尔值,指示
DoInBackground()
是否成功执行。为什么断点不停止?@sjbhalli在调用函数之前断点是否命中?
protected async override Task<bool> DoInBackground() {
    var json = await GetJson();

    Debug.WriteLine("before");
    dynamic jsonObject = JObject.Parse(json);
    Debug.WriteLine("after");

    return true;
}