5

We recently updated a bunch of dlls in our project, including HtmlAgilityPack to their latest versions. This has made the following code which had been working start throwing errors on the first line.

List<HtmlNode> foundNodes = document.QuerySelectorAll(".divider").ToList();

foreach(HtmlNode node in foundNodes){
    doWhatever(node);
}

Method not found: 'System.Collections.Generic.IEnumerable`1 HtmlAgilityPack.HtmlNode.Descendants()'.

The last line of the stack trace is:

"at Fizzler.Systems.HtmlAgilityPack.HtmlNodeOps.b__71(HtmlNode n)"

The QuerySelectorAll is returning an IEnumerable of HtmlNode, however I can't seem to be able to cast it to a list anymore. I would hazard a guess there is some related dll with an incompatible version now (fizzler?) missing the Descendants method? However the NuGet page for HtmlAgilityPack shows no dependencies, and the fizzler version I'm using is 1.0.0 which I think is correct.

James
  • 4,146
  • 1
  • 20
  • 35
  • Have you tried uninstalling both `HtmlAgilityPack` and `Fizzler`, and installing their up-to-date versions ? – Veverke Jul 04 '16 at 12:31
  • Yep, to no avail. Looking deeper at the exception it seems the `Fizzler.Systems.HtmlAgilityPack` dll is being loaded from `C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files` and is an old version, not sure why. I tried deleting the folder and reloading the project but it somehow is the same. We have started using AngleSharp instead now as it's usage is very similar so it was a simple changeover. – James Jul 04 '16 at 13:36
  • You using `AngleSharp` was my first guess (`QuerySelectorAll` is familiar to me). I suggest reproducing the problem: create a console app, install the required packages (latest versions), and issue a simple `QuerySelectorAll` call. Does it happen there as well ? If not (and it will likely not), perhaps you can also delete the `packages.config` file and then uninstall all relevant packages ? (the order might be the opposite - uninstall and then delete the file), and try installing again ? – Veverke Jul 04 '16 at 13:45

3 Answers3

10

It's happening the same error with me after I upgraded the HtmlAgilityPack nuget package.

I resolved downgrading from 1.4.9.4 to 1.4.9 for now.

Let's see the next versions of this package.

  • Hi Alberto, thanks for the response. Unfortunately I had already tried this and it didn't solve the issue for me so I'm not going to mark this as the answer (but upvoted) – James Jul 13 '16 at 14:09
  • 1
    Did you removed the files of 1.4.9.4 from packages folder? – Alberto Chvaicer Jul 25 '16 at 19:33
2

Disclaimer: I'm the owner of the project Html Agility Pack

The version 1.5.0 has been released, and this issue has been fixed in the v1.5.0-beta5.

It was caused because a default parameter was added to a method in the v1.4.9.5

Since the library is strongly named, Fizzler could not find anymore this method.

Jonathan Magnan
  • 10,874
  • 2
  • 38
  • 60
1

I had a very similar error, and rolling it back from 1.4.9.5 to version 1.4.9 resolved it, not entirely sure why though.