Can I use HTML Agility Pack in Windows Forms Applications?


This is my first time doing my work with HAP, but I find a problem with HtmlDocument class, I can't use it, because intellisense tells me that it is ambiguous reference, this is the picture : enter image description here

I have imported the library needed it this code which are using HTML_Agility; using HtmlAgilityPack; and I also add reference to its DLL file but it can't help me so much. Do you know why this happens and how to fix it?

Accepted Answer

To avoid the ambiguous reference write like this:

HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();

Popular Answer

There's also exists a System.Windows.Forms.HtmlDocument class.

Try explicitly qualifying your classname instead of using a using statement, or rename the class with a using statement such as using HAPDocument = HtmlAgilityPack.HtmlDocument; (and then use HAPDocument instead of HtmlDocument in your source code).

Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why