简体   繁体   English

绑定重定向不重定向?

[英]Binding redirect not redirecting?

I've run into an issue where I'm getting an error about something trying to load an old version of a dll that is no longer even on the machine. 我遇到了一个问题,我收到一个错误,试图加载旧版本的dll,甚至不再在机器上。

Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. 无法加载文件或程序集“Newtonsoft.Json,Version = 6.0.0.0,Culture = neutral,PublicKeyToken = 30ad4fe6b2a6aeed”或其中一个依赖项。 The located assembly's manifest definition does not match the assembly reference. 定位的程序集的清单定义与程序集引用不匹配。 (Exception from HRESULT: 0x80131040) (HRESULT异常:0x80131040)

I already had a redirect in the webconfig to deal with this: 我已经在webconfig中有一个重定向来处理这个:

<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>

There are no references to the 6.0.0.0 build in the solution. 解决方案中没有对6.0.0.0版本的引用。 A dependency perhaps? 也许依赖? If so I have no idea how to get the run time to tell me who the guilty part is. 如果是这样,我不知道如何让运行时间告诉我谁是有罪的部分。

Why is this still faulting? 为什么这仍然是错误的?

Turns out the answer was right in front of me. 事实证明答案就在我面前。 The assemblyBinding tag has an appliesTo attribute that specifies which versions should be redirected per .Net framework version. assemblyBinding标记有一个applyTo属性,指定每个.Net框架版本应重定向哪些版本。

assemblyBinding appliesTo="v2.0.50727"

For some reason it was set to v2.0 - the application is running v4.0 so the redirects where not applying. 由于某种原因,它被设置为v2.0 - 应用程序正在运行v4.0,因此重定向不适用的地方。 Removing the attribute corrects the issue. 删除属性可以解决问题。

<runtime>
    <assemblyBinding>
        <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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM