将HtmlAgilityPack的引用添加到类时出错
本文关键字:出错 添加 HtmlAgilityPack 引用 | 更新日期: 2023-09-27 18:28:54
我在将其添加到类中时遇到错误,有人知道解决方案吗?使用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)
我的包里有这个。配置
<?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>
我通过将相同的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>
希望能有所帮助。