我使用NHunspell检查拼写。我添加了NHunspell.dll作为对asp.net页面的引用。我添加了名称空间System.NHunspell。我面临的问题与IDisposible有关。我将下载的NHunspell代码放在按钮事件中。
受保护的无效发送者(object Button1_Click,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);
}
}
}
}上面显示的*是error.The错误行:“using语句中使用的类型必须隐式转换为'System.IDisposable'”。
还有一行警告:"'NHunspell.MyThes.MyThes(string,string)‘已过时:’不再需要idx文件,MyThes完全在内存中工作‘“;
有人能帮我改正这个错误吗?
好了,我把这一行改为新的thes = MyThes MyThes("th_en_us_new.dat");bug已经消失了。
但有一个异常“未找到AFF文件: E:\programfiles\visual studio\Common7\IDE\en_us.aff”。我该怎么做??
发布于 2010-04-23 00:00:26
您是否尝试将行更改为:
MyThes thes = new MyThes("th_en_us_new.dat");您是否在C:\驱动器上搜索了en_us.aff文件?在最初的NHunspell压缩下载中,您应该可以找到这个文件。将该文件复制到E:\programfiles\visual studio\Common7\IDE\目录中可能就足够了。
发布于 2010-04-23 00:01:04
如果MyThes不支持IDisposable,那么就不要使用using。对于Obsolete -在MyThes上按F12键并拾取不带过时属性的构造函数
https://stackoverflow.com/questions/2692372
复制相似问题