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

时间:2021-12-02 07:10:28

I have used the following code for spelling checking.

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

While I am running it, I get an DLLFileNotFound exception:

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

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

“未找到Hunspell Intel 32Bit DLL:C:\ project \ splee \ Hunspellx86.dll”。

Code Snippet:

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); 

                } 
            } 
        } 

I have made a reference to Hunspell.dll in the project. What's going wrong?

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

4 个解决方案

#1


5  

You need to include the native Hunspellx86.dll next to the the managed NHunspell.dll.

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

I did the following way:

我做了以下方式:

  1. Referenced NHunspell.
  2. set the Copy Local property
  3. 设置“复制本地”属性

  4. Include the NHunspellx86.dll to my project
  5. 将NHunspellx86.dll包含在我的项目中

  6. Set "Copy to output directory" property "copy if newer".
  7. 设置“复制到输出目录”属性“如果更新则复制”。

This ensures that the native Hunspell.dll will be in place.

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

#2


3  

I have replicated this error in two different scenarios using NHunspell v 0.9.4. It appears that NHunspell shows this error message for a range of issues which could occur during the process of loading the relevant unmanaged Hunspellx**.dll.

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

The first cause I found was if the particular IIS app pool running my webapp did not have 32-bit applications enabled. This, of course, is only relevant if you're running your 32-bit webapp on a 64-bit machine.

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

The second cause I found was if the IIS process user did not have appropriate permissions to read the folder containing Hunspellx**.dll. The IIS users (group called something like MACHINENAME\IIS_IUSRS) must have permission to read and execute every file in the webapp execution directory (and bin subfolder).

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

#3


1  

Ensure the Copy local setting is set to "Copy always" when you right click the NHunspell.DLL in Solution Explorer.

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

#4


0  

I had this issue in a production environment when the version of the unmanaged DLLs was slightly older than the version the ASP.Net project was built against.

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

Specifically FusLogVw showed:

特别是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.

Updating to the correct version of the unmanaged DLLs resolved the issue.

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

#1


5  

You need to include the native Hunspellx86.dll next to the the managed NHunspell.dll.

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

I did the following way:

我做了以下方式:

  1. Referenced NHunspell.
  2. set the Copy Local property
  3. 设置“复制本地”属性

  4. Include the NHunspellx86.dll to my project
  5. 将NHunspellx86.dll包含在我的项目中

  6. Set "Copy to output directory" property "copy if newer".
  7. 设置“复制到输出目录”属性“如果更新则复制”。

This ensures that the native Hunspell.dll will be in place.

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

#2


3  

I have replicated this error in two different scenarios using NHunspell v 0.9.4. It appears that NHunspell shows this error message for a range of issues which could occur during the process of loading the relevant unmanaged Hunspellx**.dll.

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

The first cause I found was if the particular IIS app pool running my webapp did not have 32-bit applications enabled. This, of course, is only relevant if you're running your 32-bit webapp on a 64-bit machine.

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

The second cause I found was if the IIS process user did not have appropriate permissions to read the folder containing Hunspellx**.dll. The IIS users (group called something like MACHINENAME\IIS_IUSRS) must have permission to read and execute every file in the webapp execution directory (and bin subfolder).

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

#3


1  

Ensure the Copy local setting is set to "Copy always" when you right click the NHunspell.DLL in Solution Explorer.

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

#4


0  

I had this issue in a production environment when the version of the unmanaged DLLs was slightly older than the version the ASP.Net project was built against.

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

Specifically FusLogVw showed:

特别是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.

Updating to the correct version of the unmanaged DLLs resolved the issue.

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