我试图在某些Windows 8.1机器上启用拼写检查时遇到异常(两者都有最新更新,操作系统语言是俄语,.NET框架4.7是俄语)说:
System.Reflection.TargetInvocationException:调用目标抛出了异常.---> System.Runtime.InteropServices.COMException:Windows.Data.Text.WordsSegmenter..ctor处的System.StubHelpers.StubHelpers.GetWinRTFactoryObject(IntPtr pCPCMD)中的注册表值(来自HRESULT的异常:0x80040153(REGDB_E_INVALIDVALUE))无效()字符串语言)---内部异常堆栈跟踪的结束---在System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr,Binder binder)的System.RuntimeMethodHandle.InvokeMethod(Object target,Object []参数,Signature sig,Boolean构造函数)中,对象[]参数,CultureInfo文化)在MS.Internal.WindowsRuntime.Windows.Data.Text.WordsSegmenter..ctor(String language)的MS.Internal.WindowsRuntime.ReflectionHelper.ReflectionNew [TArg1](类型类型,TArg1 arg1)在Syst的System.Windows.Documents.WinRTSpellerInterop.EnsureWordBreakerAndSpellCheckerForCulture(CultureInfo culture,Boolean throwOnError)的MS.Internal.WindowsRuntime.Windows.Data.Text.WordsSegmenter.Create(String language,Boolean shouldPreferNeutralSegmenter)系统.Windows.Documents.WinRTSpellerInterop..ctor()在System.Windows.Documents.SpellerInteropBase.CreateInstance()处于System.Windows.Documents.Speller.EnsureInitialized()处于System.Windows.Documents.Speller.SetCustomDictionaries(CustomDictionarySources dictionaryLocations, System.Windows上的System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)上的System.Windows.Controls.SpellCheck.OnIsEnabledChanged(DependencyObject d,DependencyPropertyChangedEventArgs e)中的System.Windows.Documents.TextEditor.SetCustomDictionaries(Boolean add)处的布尔添加)在System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs参数)在System.Windows.DependencyObject.UpdateEffectiveValue(entryIndex entryIndex,的DependencyProperty DP,PropertyMetadata元数据,EffectiveValueEntry oldEntry,EffectiveValueEntry&newEntry,布尔coerceWithDeferredReference,布尔coerceWithCu .FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs E)System.Windows.DependencyObject.SetValue(DependencyProperty dp,Object value)中的System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp,Object value,PropertyMetadata metadata,Boolean coerceWithDeferredReference,Boolean coerceWithCurrentValue,OperationType operationType,Boolean isInternal)中的rrentValue,OperationType operationType)
此代码可用于重现该问题:
var richTextBox = new RichTextBox();
InputLanguageManager.SetInputLanguage(richTextBox,CultureInfo.GetCultureInfo("en-US"));
richTextBox.SetValue(SpellCheck.IsEnabledProperty, true);
Run Code Online (Sandbox Code Playgroud)
在研究这个问题时,我发现异常是从s_WinRTType描述类型"Windows.Data.Text.WordsSegmenter,Windows,ContentType = WindowsRuntime.WindowsSegmenter似乎是WinRT组件的s_WinRTType.ReflectionNew<string>(language);地方抛出的,所以我看不到里面发生了什么.我想要要知道它为什么抛出REGDB_E_INVALIDVALUE /它寻找的值以及它应该是什么样的?谢谢!