c# – 如何解决Huenspell Intel 32位DLL未找到的异常?

前端之家收集整理的这篇文章主要介绍了c# – 如何解决Huenspell Intel 32位DLL未找到的异常?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用以下代码进行拼写检查.

当我运行它时,我得到一个DLLFileNotFound异常:

“Hunspell Intel 32Bit DLL not found: C:\project\splee\Hunspellx86.dll”.

代码片段:

using (Hunspell hunspell = new Hunspell("en_us.aff","en_us.dic")) 
    { 
        bool correct = hunspell.Spell("Recommendation"); 
        var suggestions = hunspell.Suggest("Recommendation"); 
        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); 

                } 
            } 
        }

我在项目中引用了Hunspell.dll.出了什么问题?

解决方法

您需要在托管的NHunspell.dll旁边包含本机Hunspellx86.dll.

我做了以下方式:

>参考NHunspell.
>设置“复制本地”属性
>将NHunspellx86.dll包含在我的项目中
>设置“复制到输出目录”属性“如果更新则复制”.

这可以确保本机Hunspell.dll到位.

原文链接:https://www.f2er.com/csharp/239076.html

猜你在找的C#相关文章