Method not found: 'Void Newtonsoft.Json.Serialization.DefaultContractResolver.set_IgnoreSerializableAttribute(Boolean)' (webapi and PCL)

落花浮王杯 提交于 2019-11-30 06:55:28

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.

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

Two other things that may help:

  1. Removing Temporary ASP.NET files (found in "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files") containing old versions of the NewtonSoft dll.
  2. Removing your NuGet package folder, clearing the NuGet package cache ("Manage NuGet Packages" -> "Settings" -> "NuGet Package Manager" -> "General" -> "Clear Package Cache", then restoring the packages
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!