After running a clean solution and rebuild, my MVC 4 Web API project stops working. It\'s can\'t find Newtonsoft.Json.
I know that MS is using this as the default JS
I had the same problem in VS2012 express, and I managed to install it from
TOOLS -> NuGet Package Manager -> Manage NuGet Packages for Solution
There I found and installed Newtonsoft Json. It wasn't installed in none of the projects from solution by then.
In my case I checked out a colleague's project which somehow turned my Newtonsoft.Json reference bad - so I had to remove it. Right click on the project -> Manage NuGet Packages. On the left side click "Installed Packages" then select Json.NET and uninstall it. In my case I had to uninstall other dependent packages also (Microsoft ASP.Net Web API and others). Choose "Online" on the left side and search for Json.Net, re-install it.
I did this by mistake, and it sorted it self out fine.
Having started a new VS 2012 project I used NuGet to install Newtonsoft.JSON, as mentioned version 4.5.6 is already installed, and I was impressed to see that this was uninstalled and 4.5.10 installed.
Sweet.
Check to see if you had an 'old style' (pre nuget) reference to JSON.NET pointing to an out of date local copy embedded in your project.
I had an old Reference\Lib\JSON.NET
which was in my reference path and getting priority.
Check that the JSON.NET properties page is pointing to the expected Nuget package version.
I had this problem on a Team Server build which deployed live. I had to fix my original solution and do a clean build to make sure the old Reference\Lib\
DLL wasn't being picked up.
You could try to install the SocialAuth.Net package with the ‑IgnoreDependencies flag, then installing the dependencies manually and making sure that you only install the latest version of Json.Net library.
Then at runtime the SocialAuth.Net package would respect the assembly redirect and load Json.Net (v4.5) instead of the old version.
What caused my problem with Newtonsoft.json was slightly different. I had developed a Windows app built against .Net 4.5. I later found out that the customer's environment only supported .Net 4.0. I had copied the solution to a new area to preserve the .Net 4.5 work and changed the Solution Properties to Microsoft.Net 4.0. I got the error that Newtonsoft.json could not be found and was I missing a reference.
I followed the procedures stated above for removing the packages.config; removing Newtonsoft.json; ensuring that Newtonsoft.json was removed from the \packages directory; then reinstalling Newtonsoft.json from NuGet. I was able to compile and run the application with .Net 4.0
Prior to this the packages.config file showed that the version of .Net that Newtonsoft.json targeted was .Net 4.5. Removing and adding the Newtonsoft.json now has the target as .Net 4.0.