简体   繁体   English

我可以在Windows窗体应用程序中使用HTML Agility Pack吗?

[英]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 : 这是我第一次使用HAP,但是我发现HtmlDocument类有问题,我无法使用它,因为intellisense告诉我它是含糊的引用,如下图所示: 在此处输入图片说明

I have imported the library needed it this code which are using HTML_Agility; using HtmlAgilityPack; 我已经导入了需要using HTML_Agility; using HtmlAgilityPack;代码的库using HTML_Agility; using HtmlAgilityPack; using HTML_Agility; using HtmlAgilityPack; and I also add reference to its DLL file but it can't help me so much. 并且我还添加了对其DLL文件的引用,但对我没有太大帮助。 Do you know why this happens and how to fix it? 您知道为什么会这样以及如何解决吗?

There's also exists a System.Windows.Forms.HtmlDocument class. 还存在一个System.Windows.Forms.HtmlDocument类。

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; 试着明确你的资格类名,而不是使用using语句,或用类重命名using的语句,如using HAPDocument = HtmlAgilityPack.HtmlDocument; (and then use HAPDocument instead of HtmlDocument in your source code). (然后在源代码中使用HAPDocument而不是HtmlDocument )。

为了避免歧义引用,请这样编写:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM