简体   繁体   中英

Two dependency versions of newtonsoft.json

I have a project where i need to have two different versions of newtonsoft.json. I tried to use the codeBase like this:

        <dependentAssembly>
          <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30AD4FE6B2A6AEED" culture="neutral"/>
          <codeBase version="10.0.0.0" href="dll\newtonsoft\10.0.3\Newtonsoft.Json.dll"/>
          <codeBase version="12.0.0.0" href="dll\newtonsoft\12.0.1\Newtonsoft.Json.dll"/>
        </dependentAssembly>

But now i'm getting the "Found conflicts between different versions of the same dependent assembly." exception.

I'm not sure about what version should be in the projects References, VS auto install a version in this. Hope someone can help me on the way on this one.

What you need to do here is in fact remove one of them, likely the older one. However if you remove that, umbraco would obviously stop working because it expects it to be there, right? The solution is to add a binding redirect to your web.config as specified here . Use a range for the oldVersion attribute so that anything trying to bind to version 0.0.0.0 through 12.0.1 will use the 12.0.1 that is referenced.

Note that this isn't guaranteed to work for every reference because if there have been breaking changes between 10 and 12.0.1 you'll be in trouble, but ideally that will get caught at compile time instead of runtime (if your own code is directly referencing it). If it's not your own code (because there won't be errors until runtime), you need to make sure it works as expected at runtime.

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