Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error with adding reference of HtmlAgilityPack to class

I am getting an error while adding this to my class, does somebody know the solution for this? Using 4.5 framework.

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)

I have this in my packages.config

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

packages gives a error that its not declared

I have tried to add it to debug, include it local but nothing seems to make it work

Update:

still same error adjusted it like this, but not sure if correct:

<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>
like image 374
user3763117 Avatar asked Jun 13 '26 11:06

user3763117


1 Answers

I fixed it by adding the same assemblyIdentity and bindingRedirect to the web.config (or app.config). Make sure it's in the corresponding place: inside configuration - runtime - 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>

Hope it helps.

like image 63
Ymagine First Avatar answered Jun 15 '26 03:06

Ymagine First



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!