Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I resolve a Hunspell Intel 32bit DLL not found exception?

I have used the following code for spelling checking.

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

"Hunspell Intel 32Bit DLL not found: 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?

like image 810
NikRED Avatar asked Apr 27 '10 04:04

NikRED


4 Answers

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

I did the following way:

  1. Referenced NHunspell.
  2. set the Copy Local property
  3. Include the NHunspellx86.dll to my project
  4. Set "Copy to output directory" property "copy if newer".

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

like image 165
vlacko Avatar answered Nov 07 '22 02:11

vlacko


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.

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.

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

like image 3
Lisa Avatar answered Nov 07 '22 03:11

Lisa


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

like image 1
Daniel Dyson Avatar answered Nov 07 '22 04:11

Daniel Dyson


I was able to resolve this in VB.net 2010 as follows, I assume something similar can be done in C# and later versions of VB.net:

  1. Double-click "My Project" in Solution Explorer.
  2. Click the "View Application Events" button.
  3. Add an Application Startup event like this:
 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

I believe you can also just put Hunspellx86.dll in the folder containing your application's .exe file.

like image 1
wade Avatar answered Nov 07 '22 04:11

wade