在Windows 10(1709)上运行.NET 4.5.2 WPF应用程序。如果重要的话,一些第三方程序集会针对.NET 4客户端配置文件。
在某些客户计算机上,有时 会出现以下异常。唯一的线索是他们使用的shona
语言环境是Windows最近添加的。我已经尽力重现此错误,但似乎是不可能的。在我们的开发机上,所有现有文化(包括shona)和任何定制的文化都具有有效的KeyboardLayoutId
(1033),我认为它与我在此引用的“键盘布局”相对应。
指向WPF
源代码的一些相关指针:
由于在CultureInfo.cs(407)处进行了构造函数调用,因此在InputLanguageManager.cs(289)处引发了异常。如果进一步研究,我们将找到根本原因-在 GetKeyboardLayout function (MSDN) 处调用InputLanguageSource.cs(238)。据我所知,对GetKeyboardLayout(_dispatcherThreadId)
的调用返回了LOCALE_CUSTOM_UNSPECIFIED (4096)
。 这怎么可能?!
Unhandled Exception:Culture is not supported. Parameter name: culture 4096 (0x1000) is an invalid culture identifier.
Stack Trace:
at System.Globalization.CultureInfo.InitializeFromCultureId(Int32 culture, Boolean useUserOverride)
at System.Windows.Input.InputLanguageSource.get_CurrentInputLanguage()
at System.Windows.Input.InputLanguageManager.get_CurrentInputLanguage()
at System.Windows.Documents.TextSelection.EnsureCaret(Boolean isBlinkEnabled, Boolean isSelectionActive, CaretScrollMethod scrollMethod)
at System.Windows.Documents.TextSelection.System.Windows.Documents.ITextSelection.UpdateCaretAndHighlight()
at System.Windows.Controls.Primitives.TextBoxBase.OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.KeyboardDevice.ChangeFocus(DependencyObject focus, Int32 timestamp)
at System.Windows.Input.KeyboardDevice.TryChangeFocus(DependencyObject newFocus, IKeyboardInputProvider keyboardInputProvider, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
at System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
at System.Windows.Input.KeyboardDevice.Focus(IInputElement element)
at System.Windows.UIElement.Focus()
at System.Windows.Input.KeyboardNavigation.Navigate(DependencyObject currentElement, TraversalRequest request, ModifierKeys modifierKeys, DependencyObject firstElement)
at System.Windows.FrameworkElement.MoveFocus(TraversalRequest request)
...
嗯...我该如何解决这个问题?如果有人可以提供一些有关如何重现此行为的线索,那肯定会很好。我已经尝试了一切...