将HtmlAgilityPack的引用添加到类时出错

时间:2014-11-03 20:58:16

标签: c# html-agility-pack

我在将这个添加到我的课程时遇到错误,有人知道解决方法吗? 使用4.5框架。

Could not load file or assembly 'HtmlAgilityPack, Version=1.4.9.0, Culture=neutral,   PublicKeyToken=bd319b19eaf3b43a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

我在packages.config

中有这个
<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="HtmlAgilityPack" version="1.4.9.0" targetFramework="net45" />
</packages>

包提供了一个未声明的错误

我曾尝试将其添加到调试中,将其包含在本地但似乎没有任何效果

更新

仍然是这样的错误调整它,但不确定是否正确:

<configuration>
<packages>
    <package id="HtmlAgilityPack" version="1.4.9.0" targetFramework="net45" />
</packages>
<dependentAssembly>
    <assemblyIdentity name="HtmlAgilityPack" publicKeyToken="bd319b19eaf3b43a" culture="neutral" />
    <bindingRedirect oldVersion="1.4.5.0-1.4.7.0" newVersion="1.4.9.0" />
</dependentAssembly>
</configuration>

1 个答案:

答案 0 :(得分:0)

我通过将相同的assemblyIdentity和bindingRedirect添加到web.config(或app.config)来修复了该问题。确保它在相应的位置:内部配置-运行时-assemblyBinding。

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="HtmlAgilityPack" publicKeyToken="bd319b19eaf3b43a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.11.23.0" newVersion="1.11.23.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

希望有帮助。