public HunspellSpellingPlugin() { // Set up the spell engine for multi-threaded access. SpellEngine = new SpellEngine(); // Assume we are disabled unless we can configure it properly. projectPlugin = new DisabledSpellingProjectPlugin(); // Figure out the paths to the dictionary files. For the time being, // we're going to assume we're using U.S. English. string affixFilename; string dictionaryFilename; if (!GetDictionaryPaths("en_US", out affixFilename, out dictionaryFilename)) { // We couldn't get the dictionary paths, so just stick with the // disabled spelling plugin. return; } // Attempt to load the NHunspell plugin. This is a high-quality // plugin based on Managed C++. This works nicely in Windows, but // has no support for Linux. try { // Attempt to load the U.S. English language. This will throw // an exception if it cannot load. If it does, then we use it. var englishUnitedStates = new LanguageConfig { LanguageCode = "en_US", HunspellAffFile = affixFilename, HunspellDictFile = dictionaryFilename, HunspellKey = string.Empty }; SpellEngine.AddLanguage(englishUnitedStates); // If we got this far, set the project plugin to the one that // uses the SpellEngine from NHunspell. projectPlugin = new SpellEngineSpellingProjectPlugin(this); return; } catch (Exception exception) { // Report that we can't load the first attempt. Console.WriteLine("Cannot load NHunspell: " + exception); } // If we got this far, we couldn't load the NHunspell plugin. // Attempt to load in the PInvoke implementation instead. try { // Create a new Hunspell P/Invoke loader. var pinvokePlugin = new PInvokeSpellingProjectPlugin( affixFilename, dictionaryFilename); projectPlugin = pinvokePlugin; } catch (Exception exception) { // Report that we can't load the first attempt. Console.WriteLine("Cannot load NHunspell via P/Invoke: " + exception); } }