在我的程序集中我想使用
SomeLibrary.dll -gt; Newtonsoft.Json, Version 10.0.0.0
SomeLibrary.dll
Newtonsoft.Json, Version 10.0.0.0
我引用的地方 SyelBr.DLL 通过路径。那么我也有
SyelBr.DLL
Microsoft.NET.Sdk.Functions -gt; Newtonsoft.Json, Version 9.0.0.1
Microsoft.NET.Sdk.Functions
Newtonsoft.Json, Version 9.0.0.1
它们都被nuget引用。这样做会导致版本不匹配
JsonConvert.DeserializeObject<SomeTypeFromSomeLibrary>(json)
对此我能做些什么?:(
这种问题通常通过 binding redirect .
对于json.net,它可能如下所示:
<configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration>