I've got an exception while trying to enable spell checking on some Windows 8.1 machines (both have latest updates, OS language is russian and .NET framework 4.7 is russian) saying:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException: Invalid value for registry (Exception from HRESULT: 0x80040153 (REGDB_E_INVALIDVALUE)) at System.StubHelpers.StubHelpers.GetWinRTFactoryObject(IntPtr pCPCMD) at Windows.Data.Text.WordsSegmenter..ctor(String language) --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at MS.Internal.WindowsRuntime.ReflectionHelper.ReflectionNew[TArg1](Type type, TArg1 arg1) at MS.Internal.WindowsRuntime.Windows.Data.Text.WordsSegmenter..ctor(String language) at MS.Internal.WindowsRuntime.Windows.Data.Text.WordsSegmenter.Create(String language, Boolean shouldPreferNeutralSegmenter) at System.Windows.Documents.WinRTSpellerInterop.EnsureWordBreakerAndSpellCheckerForCulture(CultureInfo culture, Boolean throwOnError) at System.Windows.Documents.WinRTSpellerInterop..ctor() at System.Windows.Documents.SpellerInteropBase.CreateInstance() at System.Windows.Documents.Speller.EnsureInitialized() at System.Windows.Documents.Speller.SetCustomDictionaries(CustomDictionarySources dictionaryLocations, Boolean add) at System.Windows.Documents.TextEditor.SetCustomDictionaries(Boolean add) at System.Windows.Controls.SpellCheck.OnIsEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType) at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal) at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
This code can be used to reproduce the issue:
var richTextBox = new RichTextBox();
InputLanguageManager.SetInputLanguage(richTextBox,CultureInfo.GetCultureInfo("en-US"));
richTextBox.SetValue(SpellCheck.IsEnabledProperty, true);
While investigation this issue I found that exception is thrown from s_WinRTType.ReflectionNew<string>(language);
where s_WinRTType describes type "Windows.Data.Text.WordsSegmenter, Windows, ContentType=WindowsRuntime. WordsSegmenter seems to be WinRT component so I can't see what's going on inside it. I want to know why does it throw REGDB_E_INVALIDVALUE / which value it looks for and how should it look like?
Thank you!
Update 1. I also saw this component's key exists in registry: So probably this component throws exception by itself