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

23,315

Solution 1

I had the same issue when running the exercise files from Scott Allen's great Pluralsight course about MVC4 fundamentals. Updating Newtonsoft.Json with the prerelease switch didn't work for me. You have to reinstall the WebApi packages. Use the following commands in the package manager console:

uninstall-package Microsoft.AspNet.WebApi
uninstall-package Microsoft.AspNet.WebApi.webhost
uninstall-package Microsoft.AspNet.WebApi.core
uninstall-package Microsoft.AspNet.WebApi.Client
uninstall-package Newtonsoft.Json

install-package Microsoft.AspNet.WebApi

I thought first, that uninstalling Microsoft.AspNet.WebApi would also take care of uninstalling webhost, core and client - but this didn't work. Reinstalling Microsoft.AspNet.WebApi then provides for the correct version of Newtonsoft.Json as a dependent assembly, though.

After that it worked perfectly.

Hope this helps.

Solution 2

I had the same issue and finally resolved by running

Update-Package Newtonsoft.Json –IncludePrerelease

in Package Manager Console.

It turned up all of my projects are on latest release but after Clean/ReBuild problems are solved.

Share:
23,315
Jonathan
Author by

Jonathan

Builder of rich interactive experiences with ranging technologies that include .net, node, sql, angular, and much more.

Updated on July 09, 2022

Comments

  • Jonathan
    Jonathan almost 2 years

    I have a ASP.net MVC application that is using portable class libraries that are shared by a xamarin application. When my web application starts now, it throws this error:

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

    I am using the Structure Map MVC nuget package and it was working fine until I referenced the PCL library.

    It errors on this line of code:

    GlobalConfiguration.Configuration.DependencyResolver = new StructureMapDependencyResolver(container);
    

    I think it has something to do with the PCL class and the MVC both having references to JSON.net. Any ideas on how to fix this? I ended up rebuilding my machine to make sure only this version was in the GAC and no where else.

    Any ideas