Why is Newtonsoft.Json so prone to assembly version conflicts?

痴心易碎 提交于 2019-12-05 08:27:16

Why is Newtonsoft.Json so prone to assembly version conflicts?

Basically, because it is commonly used as a downstream dependency by other libraries and application code. If you have package A (in this case, Netwonsoft.Json), and you have:

SomeApp
-> A

then all is great; but if you have:

SomeApp
-> A
-> SomeLib
   -> A

or:

SomeApp
-> SomeLib
   -> A
-> SomeOtherLib
   -> A

or:

SomeApp
-> A
-> SomeLib
   -> A
-> SomeOtherLib
   -> A

or:

SomeApp
-> A
-> SomeLib
   -> A
-> SomeOtherLib
   -> YetAnotherLib
      -> A
      -> MeTooLib
         -> A

then all the referenced versions of A need to be the same, or suitable assembly-binding redirects need to be in place to allow a lib that expected version 7 to silently accept version 10 without throwing a binding issue. Of course, you're still completely out of luck if the API is not binary compatible between versions 7 and 10 in a method that the older library uses.

So basically: this is a problem of popularity and re-use, and a symptom of other libraries not keeping up to date on their downstream dependencies. Json.NET sees this more than other libraries because it is used more than many other libraries, including as a dependency of other libraries.

Note that NuGet automatically adds binding redirects.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!