我们正在开发一个 WPF 应用程序,该应用程序使用 System.AddIn 框架来托管显示其他 WPF 内容的加载项。一切似乎都运行良好,但一夜之间,应用程序抛出了以下 NullReferenceException:
消息:错误:对象引用未设置为对象的实例。 StackTrace:在 System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG 和 msg,ModifierKeys 修饰符) 在 System.AddIn.Pipeline.AddInHwndSourceWrapper.TranslateAccelerator(MSG 味精,ModifierKeys 修饰符) 在 MS.Internal.Controls.AddInHost.System.Windows.Interop.IKeyboardInputSink.TranslateAccelerator(MSG& 味精,ModifierKeys 修饰符) 在 System.Windows.Interop.HwndHost.OnKeyUp(KeyEventArgs e) 在 System.Windows.UIElement.OnKeyUpThunk(对象发送者,KeyEventArgs e) 在 System.Windows.Input.KeyEventArgs.InvokeEventHandler(委托 genericHandler,对象 genericTarget) 在 System.Windows.RoutedEventArgs.InvokeHandler(委托处理程序,对象目标) 在 System.Windows.RoutedEventHandlerInfo.InvokeHandler(对象目标,RoutedEventArgs routedEventArgs) 在 System.Windows.EventRoute.InvokeHandlersImpl(对象源,RoutedEventArgs args,布尔 reRaised) 在 System.Windows.UIElement.RaiseEventImpl(RoutedEventArgs 参数) 在 System.Windows.UIElement.RaiseEvent(RoutedEventArgs 参数,布尔值信任) 在 System.Windows.Input.InputManager.ProcessStagingArea() 在 System.Windows.Input.InputManager.ProcessInput(InputEventArgs 输入) 在 System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport) 在 System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd,InputMode 模式,Int32 时间戳,RawKeyboardActions 操作,Int32 扫描代码,布尔 isExtendedKey,布尔 isSystemKey,Int32 虚拟键) 在 System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(味精和味精,布尔值&处理) 在 System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(味精和味精,ModifierKeys 修饰符) 在 System.Windows.Interop.HwndSource.OnPreprocessMessage(对象参数) 在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(委托回调,对象参数,布尔 isSingleParameter) 在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(对象源,委托回调,对象 args,布尔 isSingleParameter,委托 catchHandler) 在 System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority 优先级,TimeSpan 超时,委托方法,对象参数,布尔 isSingleParameter) 在 System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority 优先级,委托方法,对象 arg) 在 System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(味精和味精,布尔值&处理) 在 System.Windows.Interop.HwndSource.WeakEventPreprocessMessage.OnPreprocessMessage(MSG& 味精,布尔值& 处理) 在 System.Windows.Interop.ThreadMessageEventHandler.Invoke(MSG&味精,布尔&处理) 在 System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(味精和味精) 在 System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame 框架) 在 System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame 框架) 在 System.Windows.Threading.Dispatcher.Run() 在 System.Windows.Application.RunInternal(窗口窗口) 在 System.Windows.Application.Run(窗口窗口) 在 System.Windows.Application.Run()
正如你所看到的,我们的代码都没有在堆栈跟踪中,所以我没有地方修复任何东西。有人对可能的解决方法有任何想法吗?
谢谢您的帮助!