Why .net shows version conflict for same nuget package which is internal dependency for 3rd party library/package?

1

Conflicting versions of Newtonsoft.json library.

Steps to Reproduce issue:

  1. Create 2 .net c# project
  2. Project 1 include IdentityModel with some method
  3. Project 2 include Microsoft.AspNet.WebApi.OwinSelfHost with some method
  4. Pack them and create nuget package and publish it locally (2 package will get created)
  5. Now create a test project and install both nuget package in it.
  6. Call the method from those installed packages. You will get conflict error regarding Newtonsoft.json

I have two custom plugin developed on top of Kafka and REST. To fullfill the plugin I am using 3rd party libraries as part of dependency. Dependency internally uses Newtonsoft.Json package with their specific version.

package use for developing kafka plugin package use for developing kafka plugin

package use for developing REST plugin package use for developing REST plugin

.net should not show the error

System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation. ----> System.IO.FileLoadException : Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

as 3rd party library should refer their package according to their version. For me if I navigate to

%USERPROFILE%.nuget\packages

location I can see version graph versions for newtonsoft.json and 3rd party lib should use them at runtime. Version 6.0.4 and 11.0.2 should load at it's runtime.

c#
.net
json.net
nuget-package
asked on Stack Overflow Apr 3, 2019 by Sushil Tade • edited Apr 3, 2019 by Sushil Tade

1 Answer

0

please use Update-Package command to update all the packages in all projects

answered on Stack Overflow Apr 3, 2019 by Mahmoud-Abdelslam

User contributions licensed under CC BY-SA 3.0