zoukankan      html  css  js  c++  java
  • WPF PasswordBox鼠标进入时程序异常退出的解决办法

    最近在开发了一个程序中用到了PasswordBox控件,但是在程序给别人用的时候,鼠标一进入控件时程序就异常退出,查了下windows日志,错误显示如下:

    应用程序: WpfPasswordTest2.exe
    Framework 版本: v4.0.30319
    说明: 应用程序通过 System.Environment.FailFast(string message) 请求终止进程。
    消息: 不可恢复的系统错误。
    堆栈:
       在 System.Environment.FailFast(System.String)
       在 MS.Internal.Invariant.FailFast(System.String, System.String)
       在 MS.Internal.Invariant.Assert(Boolean)
       在 System.Windows.Media.FontFamily.get_FirstFontFamily()
       在 System.Windows.Media.FontFamily.get_LineSpacing()
       在 System.Windows.Documents.TextSelection.CalculateCaretRectangle(System.Windows.Documents.ITextSelection, System.Windows.Documents.ITextPointer)
       在 System.Windows.Documents.TextSelection.UpdateCaretStateWorker(System.Object)
       在 System.Windows.Documents.TextSelection.UpdateCaretState(System.Windows.Documents.CaretScrollMethod)
       在 System.Windows.Documents.TextSelection.EnsureCaret(Boolean, Boolean, System.Windows.Documents.CaretScrollMethod)
       在 System.Windows.Documents.TextSelection.System.Windows.Documents.ITextSelection.UpdateCaretAndHighlight()
       在 System.Windows.Documents.TextEditor.OnGotKeyboardFocus(System.Object, System.Windows.Input.KeyboardFocusChangedEventArgs)
       在 System.Windows.Controls.PasswordBox.OnGotKeyboardFocus(System.Windows.Input.KeyboardFocusChangedEventArgs)
       在 System.Windows.UIElement.OnGotKeyboardFocusThunk(System.Object, System.Windows.Input.KeyboardFocusChangedEventArgs)
       在 System.Windows.Input.KeyboardFocusChangedEventArgs.InvokeEventHandler(System.Delegate, System.Object)
       在 System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate, System.Object)
       在 System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object, System.Windows.RoutedEventArgs)
       在 System.Windows.EventRoute.InvokeHandlersImpl(System.Object, System.Windows.RoutedEventArgs, Boolean)
       在 System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject, System.Windows.RoutedEventArgs)
       在 System.Windows.UIElement.RaiseTrustedEvent(System.Windows.RoutedEventArgs)
       在 System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs, Boolean)
       在 System.Windows.Input.InputManager.ProcessStagingArea()
       在 System.Windows.Input.InputManager.ProcessInput(System.Windows.Input.InputEventArgs)
       在 System.Windows.Input.KeyboardDevice.ChangeFocus(System.Windows.DependencyObject, Int32)
       在 System.Windows.Input.KeyboardDevice.TryChangeFocus(System.Windows.DependencyObject, System.Windows.Input.IKeyboardInputProvider, Boolean, Boolean, Boolean)
       在 System.Windows.Input.KeyboardDevice.Focus(System.Windows.DependencyObject, Boolean, Boolean, Boolean)
       在 System.Windows.Input.KeyboardDevice.Focus(System.Windows.IInputElement)
       在 System.Windows.UIElement.Focus()
       在 System.Windows.Documents.TextEditorMouse.MoveFocusToUiScope(System.Windows.Documents.TextEditor)
       在 System.Windows.Documents.TextEditorMouse.OnMouseDown(System.Object, System.Windows.Input.MouseButtonEventArgs)
       在 System.Windows.Controls.PasswordBox.OnMouseDown(System.Windows.Input.MouseButtonEventArgs)
       在 System.Windows.UIElement.OnMouseDownThunk(System.Object, System.Windows.Input.MouseButtonEventArgs)
       在 System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(System.Delegate, System.Object)
       在 System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate, System.Object)
       在 System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object, System.Windows.RoutedEventArgs)
       在 System.Windows.EventRoute.InvokeHandlersImpl(System.Object, System.Windows.RoutedEventArgs, Boolean)
       在 System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject, System.Windows.RoutedEventArgs)
       在 System.Windows.UIElement.RaiseTrustedEvent(System.Windows.RoutedEventArgs)
       在 System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs, Boolean)
       在 System.Windows.Input.InputManager.ProcessStagingArea()
       在 System.Windows.Input.InputManager.ProcessInput(System.Windows.Input.InputEventArgs)
       在 System.Windows.Input.InputProviderSite.ReportInput(System.Windows.Input.InputReport)
       在 System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr, System.Windows.Input.InputMode, Int32, System.Windows.Input.RawMouseActions, Int32, Int32, Int32)
       在 System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr, MS.Internal.Interop.WindowMessage, IntPtr, IntPtr, Boolean ByRef)
       在 System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
       在 MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
       在 MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
       在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
       在 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
       在 System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
       在 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
       在 MS.Win32.UnsafeNativ
    View Code

    后面经查证,是由于系统字体的原因,具体的解决办法如下:

    1.在一台正常运行passwordbox控件的电脑中,拷贝C:WindowsFonts下的所有文件

    2.将拷贝的文件复制到C:WindowsFonts下,提示安装,选择全部覆盖安装即可。

    3.重新运行程序,发现这个问题已经解决了。

  • 相关阅读:
    深入理解计算机系统 第六章 存储器层次结构 第二遍
    深入理解计算机系统 第六章 存储器层次结构
    深入理解计算机系统 第八章 异常控制流 Part2 第二遍
    深入理解计算机系统 第八章 异常控制流 part2
    深入理解计算机系统 第八章 异常控制流 Part1 第二遍
    深入理解计算机系统 第八章 异常控制流 part1
    深入理解计算机系统 第三章 程序的机器级表示 Part2 第二遍
    深入理解计算机系统 第三章 程序的机器级表示 part2
    深入理解计算机系统 第三章 程序的机器级表示 Part1 第二遍
    深入理解计算机系统 第三章 程序的机器级表示 part1
  • 原文地址:https://www.cnblogs.com/sczmzx/p/4181976.html
Copyright © 2011-2022 走看看