Sunday, March 1, 2015

Newtonsoft.Json file gets overwritten in Visual Studio 2013

I was working with compiling a solution in Visual Studio 2013 and I noticed that each time I completely re-built the solution, I would end up with an older version of the Newtonsoft.Json assembly each time!

This, of course, resulted in the dreaded error message:

Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies

When I looked in the bin directory for my application, it was referencing a much older version of the Newtonsoft.Json assembly!!

In fact, it was a version that was not being referenced anywhere in my application and yet it was still copying it to the bin directory!!

I did a bit of Internet hunting and came across this post: http://stackoverflow.com/questions/22490967/visual-studio-keeps-overwriting-newtonsoft-json-dll-with-an-older-version

This post, in turn refers to this Microsoft Connect item: https://connect.microsoft.com/VisualStudio/feedback/details/850425/windows-azure-vs-tools-breaking-msbuild-for-web-projects

I decided to look at my file system to confirm this was the issue and this was what I found:







The Newtonsoft.Json assembly version was exactly the same version that was ending up in my bin folder!!

Well, fortunately, there was a newer release of the Windows Azure SDK available for Visual Studio 2013, so I decided to install it:











After installing it and checking my file system once again, this was the new file system structure:




As expected, when I rebuilt the solution a subsequent time, it compiled successfully with the correct version of the Newtonsoft.Json assembly and no assembly binding errors!!  Yippee!!

NOTE: If after updating the Windows Azure SDK Tools STILL does not work for you,  you can try completely uninstalling the Windows Azure Tools for Visual Studio and that should definitely resolve the problem.


No comments:

Post a Comment