【发布时间】:2011-10-24 08:42:12
【问题描述】:
我正在使用 NHunspell 来检查拼写。我添加了 NHunspell.dll 作为对我的 asp.net 页面的引用。我添加了命名空间 System.NHunspell。 我面临的问题与 IDisposible 有关。 我把下载的NHunspell的代码放在按钮事件里面。
protected void Button1_Click(object sender, EventArgs e) {
using (Hunspell hunspell = new Hunspell("en_us.aff", "en_us.dic"))
{
bool correct = hunspell.Spell("Recommendation");
var suggestions = hunspell.Suggest("Recommendatio");
foreach (string suggestion in suggestions)
{
Console.WriteLine("Suggestion is: " + suggestion);
}
}
// Hyphen
using (Hyphen hyphen = new Hyphen("hyph_en_us.dic"))
{
var hyphenated = hyphen.Hyphenate("Recommendation");
}
* using (MyThes thes = new MyThes("th_en_us_new.idx", "th_en_us_new.dat"))
{
using (Hunspell hunspell = new Hunspell("en_us.aff", "en_us.dic"))
{
ThesResult tr = thes.Lookup("cars", hunspell);
foreach (ThesMeaning meaning in tr.Meanings)
{
Console.WriteLine(" Meaning: " + meaning.Description);
foreach (string synonym in meaning.Synonyms)
{
Console.WriteLine(" Synonym: " + synonym);
}
}
}
}
上面显示的*是错误行。错误是: " 在 using 语句中使用的类型必须隐式转换为 'System.IDisposable'"。
该行还有一条警告:“'NHunspell.MyThes.MyThes(string, string)' 已过时:'idx 文件不再需要,MyThes 完全在内存中工作'”;
谁能帮我改正这个???
好的,我将该行更改为 MyThes thes = new MyThes("th_en_us_new.dat");错误消失了。
但是有一个异常“AFF File not found: E:\programfiles\visual studio\Common7\IDE\en_us.aff”。我该怎么办??
【问题讨论】:
标签: c#