繁体   English   中英

错误CS0246:找不到类型或名称空间名称“ HtmlAgilityPack”

[英]Error CS0246: The type or namespace name `HtmlAgilityPack' could not be found

我目前正在开发一种自然语言处理程序,在该程序中,我正在为字典访问Google翻译以翻译用户输入。

using UnityEngine;
using System.Collections;
using System.Text;
using System.Net;
public class GoogleTranslate : MonoBehaviour {
    public static string Translate(string input, string languagePair, Encoding encoding)
    {
        string url = String.Format("http://www.google.com/translate_t?hl=en&ie=UTF8&text=       {0}&langpair={1}", input, languagePair);
        string result = String.Empty;

        using (WebClient webClient = new WebClient())
        {
            webClient.E ncoding = encoding;
            result = webClient.DownloadString(url);
        }

        HtmlDocument doc = new HtmlDocument();
        doc.LoadHtml(result);
        return doc.DocumentNode.SelectSingleNode("//textarea[@name='utrans']").InnerText;
    }
}

当我在Assembly中编译该程序时,实际上是在使用Unity,但是在Assembly中编译时,出现了返回错误:

Assets/GoogleTranslate.cs(17,13): error CS0246: The type or namespace name `HtmlDocument' could not be found. Are you missing a using directive or an assembly reference?

我开始在线查找HtmlDocument的正确名称空间,并读到我应该写的内容:

using HtmlAgilityPack;

将其放入程序后,我收到错误消息:

Assets/GoogleTranslate.cs(5,7): error CS0246: The type or namespace name `HtmlAgilityPack' could not be found. Are you missing a using directive or an assembly reference?

我在网上阅读到我必须更加具体和使用:

using HtmlAgilityPack.HtmlDocument;

现在,我将其输入,仍然继续收到错误:

Assets/GoogleTranslate.cs(5,7): error CS0246: The type or namespace name `HtmlAgilityPack' could not be found. Are you missing a using directive or an assembly reference?

我想知道用于HtmlDocument的名称空间。 在这个问题上的任何帮助将不胜感激!

您是否已下载并引用了HtmlAgilityPack dll? 似乎您正在尝试使用(第三方)库,而不在项目/解决方案中的任何地方引用它。

您可以使用Nu-Get安装该库。

Install-Package HtmlAgilityPack

暂无
暂无

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

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