Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 926
Jonathan Avatar asked Jun 06 '14 16:06

Jonathan


2 Answers

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.

like image 132
ITevfik Avatar answered Oct 03 '22 09:10

ITevfik


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.

like image 20
Agent_K Avatar answered Oct 03 '22 07:10

Agent_K