【发布时间】:2012-10-10 14:06:14
【问题描述】:
我正在开发一个语言翻译程序,我从离线获取信息。我正在使用 Unity 游戏引擎,它使用 Assembly 作为其 IDE。以下是我目前的代码。
class Dictionary
{
public 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.Encoding = encoding;
result = webClient.DownloadString(url);
}
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(result);
return doc.DocumentNode.SelectSingleNode("//textarea[@name='utrans']").InnerText;
}
}
但是,在编译时,我收到错误:
Assets/DictionarySp.cs(8,7): error CS0246: The type or namespace name `HtmlAgilityPack' could not be found. Are you missing a using directive or an assembly reference?
我开始做研究,听说 HtmlAgilityPack 是第三方软件,我必须引用 .dll。我下载了 VisualStudio2010 以及 NuGet。在 Visual Studio 中,我单击“管理 NuGet 包”并安装了 HtmlAgilityPack。在 Visual Studio 内部,错误消失了,但是当我尝试在 Assembly 中打开文件时,我仍然收到找不到命名空间 HtmlAgilityPack 的错误。我正在使用 Unity 游戏引擎,所以我必须从 VisualStudio 文件中获取文件并将其放在不同的文件夹中。是否有一些我遗漏的步骤,或者我需要在汇编中做一些事情来引用 HtmlAgilityPack dll?任何帮助将不胜感激。
【问题讨论】:
-
您是否将 HtmlAgilityPack 的 bin 移动到带有 your 程序集的已部署文件夹中?
-
stackoverflow.com/questions/12628449/… 没有回答您的问题吗?
-
统一标签适用于 Microsoft Unity。请不要滥用它。
标签: c# unity3d .net-assembly