代码之家  ›  专栏  ›  技术社区  ›  user7127000

是否可以解决此程序集不匹配的情况?还是无法解决?

  •  2
  • user7127000  · 技术社区  · 8 年前

    在我的程序集中我想使用

    SomeLibrary.dll -gt; Newtonsoft.Json, Version 10.0.0.0

    我引用的地方 SyelBr.DLL 通过路径。那么我也有

    Microsoft.NET.Sdk.Functions -gt; Newtonsoft.Json, Version 9.0.0.1

    它们都被nuget引用。这样做会导致版本不匹配

    JsonConvert.DeserializeObject<SomeTypeFromSomeLibrary>(json)

    对此我能做些什么?:(

    1 回复  |  直到 8 年前
        1
  •  4
  •   vcsjones    8 年前

    这种问题通常通过 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>
    
    推荐文章