How can I fix assembly version conflicts with JSON.NET after updating NuGet package references in a new ASP.NET MVC 5 project?

后端 未结 11 1609
粉色の甜心
粉色の甜心 2020-11-29 20:42

I created a new ASP.NET MVC 5 web project in VS 2013 (Update 1) then updated all NuGet packages. When I build the project, I get the following warning:

<
11条回答
  •  温柔的废话
    2020-11-29 21:31

    I had similar issue and just wanted to post an answer for others in my situation.

    I have a solution running a ASP.NET Web Application with multiple other C# class lib projects.

    My ASP.NET Web Application wasn't using json, but other projects where.

    This is how I fixed it:

    1. I made sure all projects where using latest version (6) using NuGet Update on all projects currently using any version of json - this didn't fix the issue
    2. I added json to the web application using NuGet - this fixed the issue (let me dive into why):

    Step 2 was first of all adding a configuration information for json, that suggest that all projects, use the latest version (6) no matter what version they have. Adding the assembly binding to Web.Config is most likely the fix.

    However, step 2 also cleaned up som legacy code. It turned out we have previously used an old version (5) of json in our Web Application and the NuGet folders wasn't deleted when the reference was (I suspect: manually) removed. Adding the latest json (6), removed the old folders (json v5). This might be part of the fix as well.

提交回复
热议问题