Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTMLAgilityPack QuerySelectorAll throwing exception, potentially Fizzler dll version mismatch?

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.

like image 762
James Avatar asked Jul 04 '16 10:07

James


2 Answers

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.

like image 99
Alberto Chvaicer Avatar answered Oct 15 '22 17:10

Alberto Chvaicer


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.

like image 22
Jonathan Magnan Avatar answered Oct 15 '22 19:10

Jonathan Magnan