6

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

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

“未找到 Hunspell 英特尔 32 位 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); 

                } 
            } 
        } 

我在项目中做了参考Hunspell.dll。怎么了?

4

5 回答 5

5

您需要Hunspellx86.dll在托管的NHunspell.dll.

我做了以下方式:

  1. 引用NHunspell.
  2. 设置复制本地属性
  3. 包括NHunspellx86.dll到我的项目中
  4. 设置“复制到输出目录”属性“如果较新则复制”。

这确保了本机 Hunspell.dll 将就位。

于 2010-12-26T19:19:20.057 回答
3

我已经使用 NHunspell v 0.9.4 在两种不同的场景中复制了这个错误。NHunspell 似乎针对加载相关非托管 Hunspellx**.dll 过程中可能发生的一系列问题显示此错误消息。

我发现的第一个原因是如果运行我的 webapp 的特定 IIS 应用程序池没有启用 32 位应用程序。当然,这仅在您在 64 位机器上运行 32 位 webapp 时才有意义。

我发现的第二个原因是如果 IIS 进程用户没有适当的权限来读取包含 Hunspellx**.dll 的文件夹。IIS 用户(称为 MACHINENAME\IIS_IUSRS 之类的组)必须有权读取和执行 webapp 执行目录(和 bin 子文件夹)中的每个文件。

于 2011-10-21T06:37:45.337 回答
1

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

于 2010-07-15T18:49:01.197 回答
1

我能够在 VB.net 2010 中解决此问题,如下所示,我假设可以在 C# 和更高版本的 VB.net 中完成类似的操作:

  1. 在解决方案资源管理器中双击“我的项目”。
  2. 单击“查看应用程序事件”按钮。
  3. 添加一个应用程序启动事件,如下所示:
 Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup
     Hunspell.NativeDllPath = "D:\VB.net\_system\hunspell\dll\" '(replace path with folder containing Hunspellx86.dll)
 End Sub

我相信您也可以将 Hunspellx86.dll 放在包含应用程序 .exe 文件的文件夹中。

于 2018-12-25T13:21:51.893 回答
0

当非托管 DLL 的版本比构建 ASP.Net 项目的版本稍旧时,我在生产环境中遇到了这个问题。

具体来说 FusLogVw 显示:

LOG: Assembly download was successful. Attempting setup of file: C:\ThePath\Hunspellx64.dll
LOG: Entering download cache setup phase.
ERR: Error extracting manifest import from file (hr = 0x80131018).
ERR: Setup failed with hr = 0x80131018.
ERR: Failed to complete setup of assembly (hr = 0x80131018). Probing terminated.

更新到正确版本的非托管 DLL 解决了该问题。

于 2013-06-13T04:33:16.077 回答