Thursday, September 8, 2016

NEWTONSOFT JSON DLL VERSION MISMATCH ISSUE IN VS 2012

This post explains the issue that you could encounter when you install Visual Studio 2015 Community Edition side by side with Visual Studio 2012 and try to create ASP.NET MVC 4 application using VS2012.
I had Visual Studio Professional 2012 and .NET framework 4.5 installed. Later working on a project in Azure demanded Visual Studio 2015 to be installed. I installed VS 2015 Community edition. As a part of it .NET Framework versions 4.5.1, 4.6, 4.6.1 got installed.
After installation of VS 2015, if you try to open VS 2012 you might often see the below error. Click OK and proceed. Refer to this link for more details.

Now create an ASP.NET MVC 4 application using Basic template. If you try to run the application as such, you would see the below error.

The reason for this is the application is expecting Newtonsoft.Json.dll version 6 but only version 4.5 DLL is added by Visual studio 2012 as part of project creation. You cannot replace this with higher version because there are other dependencies on this DLL. Below snapshots show contents of web.config file and Newtonsoft.Json.dll file properties.


To resolve this issue, change the oldVersion and newVersion attribute values to point to version 4.5 DLL as below. Now your application shall run as expected. Test by adding a view and controller.

No comments:

Post a Comment