如何解决Hunspell Intel 32bit DLL未找到的异常?

Nik*_*RED 6 c# asp.net hunspell

我使用以下代码进行拼写检查.

当我运行它时,我得到一个DLLFileNotFound例外:

"未找到Hunspell Intel 32Bit DLL: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); 

                } 
            } 
        } 
Run Code Online (Sandbox Code Playgroud)

Hunspell.dll在项目中提到了一个参考.出了什么问题?

小智 5

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

我做了以下方式:

  1. 参考NHunspell.
  2. 设置"复制本地"属性
  3. 包括NHunspellx86.dll我的项目
  4. 设置"复制到输出目录"属性"如果更新则复制".

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


Dan*_*son 1

在解决方案资源管理器中右键单击 NHunspell.DLL 时,确保“复制本地”设置设置为“始终复制”。