我正在开发一个语言翻译程序,我从离线获取信息。我正在使用 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?任何帮助将不胜感激。