首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误CS0246:找不到类型或命名空间名称` `HtmlAgilityPack‘

错误CS0246:找不到类型或命名空间名称` `HtmlAgilityPack‘
EN

Stack Overflow用户
提问于 2012-09-26 01:11:47
回答 1查看 10.9K关注 0票数 5

我目前正在开发一个自然语言处理程序,在该程序中,我正在访问Google Translate以获取我的字典,以便翻译用户输入的内容。

代码语言:javascript
复制
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;
    }
}

当我用汇编语言编译这个程序时,我实际上是在使用Unity,但它是用汇编语言编译的,我得到了返回错误:

代码语言:javascript
复制
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的适当名称空间,并读到我应该这样写:

代码语言:javascript
复制
using HtmlAgilityPack;

在将这段代码放入我的程序后,我收到了错误:

代码语言:javascript
复制
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?

我在网上读到,我必须更具体地使用:

代码语言:javascript
复制
using HtmlAgilityPack.HtmlDocument;

现在我把它放进去了,我仍然继续收到这个错误:

代码语言:javascript
复制
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的名称空间是什么。在这个问题上的任何帮助都将不胜感激!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-09-26 01:15:37

你下载并引用HtmlAgilityPack动态链接库了吗?似乎您正在尝试使用(第三方)库,而没有在项目/解决方案中的任何地方引用它。

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

代码语言:javascript
复制
Install-Package HtmlAgilityPack
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12587848

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档