【发布时间】:2018-04-19 15:11:29
【问题描述】:
我在尝试在某些 Windows 8.1 机器上启用拼写检查时遇到了一个异常(两者都有最新更新,操作系统语言是俄语,.NET framework 4.7 是俄语)说:
System.Reflection.TargetInvocationException:调用的目标已抛出异常。 ---> System.Runtime.InteropServices.COMException:值无效 注册表(来自 HRESULT 的异常:0x80040153 (REGDB_E_INVALIDVALUE)) 在 System.StubHelpers.StubHelpers.GetWinRTFactoryObject(IntPtr pCPCMD) 在 Windows.Data.Text.WordsSegmenter..ctor(字符串语言)---结束 内部异常堆栈跟踪 --- 在 System.RuntimeMethodHandle.InvokeMethod(对象目标,对象 [] 参数,签名 sig,布尔构造函数)在 System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr、Binder binder、Object[] 参数、CultureInfo 文化) 在 MS.Internal.WindowsRuntime.ReflectionHelper.ReflectionNew[TArg1](类型 类型,TArg1 arg1) 在 MS.Internal.WindowsRuntime.Windows.Data.Text.WordsSegmenter..ctor(字符串 语言)在 MS.Internal.WindowsRuntime.Windows.Data.Text.WordsSegmenter.Create(字符串 语言,布尔值 shouldPreferNeutralSegmenter) 在 System.Windows.Documents.WinRTSpellerInterop.EnsureWordBreakerAndSpellCheckerForCulture(CultureInfo 文化,布尔 throwOnError)在 System.Windows.Documents.WinRTSpellerInterop..ctor() 在 System.Windows.Documents.SpellerInteropBase.CreateInstance() 在 System.Windows.Documents.Speller.EnsureInitialized() 在 System.Windows.Documents.Speller.SetCustomDictionaries(CustomDictionarySources 字典位置,布尔添加)在 System.Windows.Documents.TextEditor.SetCustomDictionaries(布尔添加) 在 System.Windows.Controls.SpellCheck.OnIsEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 在 System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs 吃 System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs 吃 System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs 参数)在 System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex,DependencyProperty dp,PropertyMetadata 元数据, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference,布尔 coerceWithCurrentValue, 操作类型操作类型)在 System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, 对象值、PropertyMetadata 元数据、布尔值 coerceWithDeferredReference,布尔 coerceWithCurrentValue, OperationType operationType, Boolean isInternal) at System.Windows.DependencyObject.SetValue(DependencyProperty dp,对象 值)
此代码可用于重现问题:
var richTextBox = new RichTextBox();
InputLanguageManager.SetInputLanguage(richTextBox,CultureInfo.GetCultureInfo("en-US"));
richTextBox.SetValue(SpellCheck.IsEnabledProperty, true);
在调查此问题时,我发现s_WinRTType.ReflectionNew<string>(language); 引发了异常,其中 s_WinRTType 描述了类型“Windows.Data.Text.WordsSegmenter, Windows, ContentType=WindowsRuntime。WordsSegmenter 似乎是 WinRT 组件,所以我看不到它里面发生了什么。我想知道它为什么会抛出 REGDB_E_INVALIDVALUE / 它寻找哪个值以及它应该是什么样子?
谢谢!
【问题讨论】:
标签: c# wpf windows-runtime richtextbox spell-checking