NHunspell Hyphenation crashing without any error or exception

16 Views Asked by At

I am trying to use NHunspell NuGet package to hyphenate words in an ASP.NET MVC application.

Here is the code that crashes the application:

using NHunspell;

namespace MyApp.Hyphenation.NHunspell;

public class ConcreteHyphenator : IHyphenator
{
    public string Hyphenate(string text, string language = "")
    {
        using var hyphenator = string.IsNullOrEmpty(language) ? new Hyphen("..\\MyApp.Hyphenation.NHunspell\\Assets\\en.dic") : new Hyphen(language);

        return hyphenator.Hyphenate(text).HyphenatedWord; // APP CRASHES HERE
    }
}

I am using the 1.2.5544.16953 version of the NHunspell package and .NET 7.

I did need to copy the Hunspellx64.dll manually from the C:\Users\my-name\.nuget\packages\nhunspell\1.2.5554.16953\content to the MyApp's bin directory. I couldn't instantiate the Hyphen class at all before that.

When checking the Windows error log, I got this error code: 0xc0000374.

I also confirmed that the .dic file is properly loading by calling File.ReadAllBytes on the same path, and it worked fine. Suppling the resulting byte array to the Hyphen constructor worked as well.

But the call to the Hyphenate method crashes every time.

Any ideas on where to go from here?

0

There are 0 best solutions below