9

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

Jonathan
  • 1,725
  • 3
  • 19
  • 45
  • Same issue. I am able to run my website in IISExpress but as soon as I debug my Android project it seems to overwrite the dll or something like that and I get this error. – Guillaume Jul 16 '14 at 12:24
  • 1
    I hit this exact problem. It's not actually a dup of the question suggested; the difference is that this one is caused by the PCL library OP mentioned. Because I can't answer this question (now that it's marked as a dup), I asked & answered another question [here](http://stackoverflow.com/questions/27812705/method-not-found-void-newtonsoft-json-serialization-defaultcontractresolver-se/27812706#27812706) – dbruning Jan 07 '15 at 05:06
  • Yes @dbruning this is not a duplicate. – MemeDeveloper Aug 31 '17 at 16:29

2 Answers2

35

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.

Agent_K
  • 815
  • 8
  • 12
  • 1
    this worked for me, i believe this issue that affected me and my team was related to windows update. – JGilmartin Nov 10 '14 at 13:26
  • 5
    Worked for my old MVC4 application with change of the last line to `install-package Microsoft.AspNet.WebApi -Version 4.0.30506` – Tae-Sung Shin Nov 26 '14 at 18:50
10

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.

ITevfik
  • 184
  • 1
  • 5