【问题标题】:Is it possible to resolve this assembly mismatch situation? Or is this unresolvable?是否有可能解决这种装配不匹配的情况?或者这是无法解决的?
【发布时间】:2019-01-01 04:40:06
【问题描述】:

在我的程序集中我想使用

SomeLibrary.dll -> Newtonsoft.Json, Version 10.0.0.0

我通过路径引用SomeLibrary.dll。那我也有

Microsoft.NET.Sdk.Functions -> Newtonsoft.Json, Version 9.0.0.1

它们都被 Nuget 引用。当我这样做时,这会导致版本不匹配

JsonConvert.DeserializeObject<SomeTypeFromSomeLibrary>(json)

对此我能做些什么? :(

【问题讨论】:

    标签: c# .net nuget .net-assembly versioning


    【解决方案1】:

    此类问题通常通过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>
    

    【讨论】:

      猜你喜欢
      • 2011-08-24
      • 1970-01-01
      • 2019-10-12
      • 2017-01-02
      • 2021-11-18
      • 2017-06-30
      • 2011-04-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多