本文介绍了找不到方法:“虚空Newtonsoft.Json.Serialization.DefaultContractResolver.set_IgnoreSerializableAttribute(布尔)'(的WebAPI和PCL)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

类似this问题,被标记为重复(所以我不能直接回答这个问题)。

Similar to this question, which was marked as a duplicate (so I couldn't answer it directly).

我有一个的WebAPI项目,它引用PCL项目。
我间歇收到此错误DefaultContractResolver

I have a webapi project, which references a PCL project.I was getting this DefaultContractResolver error intermittently.

我试过所有的与其他问题的故障排除步骤,主要涉及卸载和重新安装的NuGet包。没有帮助。

I had tried all of the troubleshooting steps from that other question, largely involving uninstalling and reinstalling the nuget packages. Didn't help.

推荐答案

对于我来说,问题的根本原因是,无论我的WebAPI项目,我PCL项目被引用Newtonsoft.Json.dll。似乎有某种在Visual Studio中建立竞争条件,因此,如果PCL项目建成最后,将其Newtonsoft.Json.dll携带版复制到我的WebAPI项目的\\ bin目录。

The root cause of the problem for me was that both my webapi project and my PCL project were referencing Newtonsoft.Json.dll. There seemed to be some kind of race condition in Visual Studio build, so that if the PCL project was built last, it would copy its portable version of Newtonsoft.Json.dll into my webapi project's \bin directory.

解决方案是简单地进入我的PCL项目的引用,并关闭复制本地的Newtonsoft.Json.dll

The solution was simply to go into my PCL project's References, and turn off "Copy local" for Newtonsoft.Json.dll

这篇关于找不到方法:“虚空Newtonsoft.Json.Serialization.DefaultContractResolver.set_IgnoreSerializableAttribute(布尔)'(的WebAPI和PCL)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 18:35