我正在从一个语言翻译程序中获取离线信息。我正在使用Unity游戏引擎,它使用Assembly作为它的IDE。以下是我的代码到目前为止。从汇编引用.dll c#
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的*仓*到部署文件夹** **你组装? –
难道http://stackoverflow.com/questions/12628449/html-agility-pack-implementation没有回答你的问题吗? –
统一标签用于Microsoft Unity。请不要滥用它。 –