将其添加到我的班级时出现错误,有人知道解决方案吗?
使用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>
最佳答案
我通过将相同的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>
希望能帮助到你。
关于c# - 将HtmlAgilityPack的引用添加到类时出错,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26723095/