简体   繁体   中英

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

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 用于开发kafka插件的软件包

package use for developing REST plugin 包用于开发REST插件

.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 版本 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.

请使用Update-Package命令更新所有项目中的所有软件包

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM