We are developing a WPF application that uses the System.AddIn structure to host add-ins that display additional WPF content. Everything seems to be working fine, but in one night the application threw the following NullReferenceException:
Message: Error: Object reference not set to an instance of an object.
StackTrace: at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator (MSG & msg, ModifierKeys modifiers)
at System.AddIn.Pipeline.AddInHwndSourceWrapper.TranslateAccelerator (MSG msg, ModifierKeys modifiers)
at MS.Internal.Controls.AddInHost.System.Windows.Interop.IKeyboardInputSink.TranslateAccelerator (MSG & msg, ModifierKeys modifiers)
at System.Windows.Interop.HwndHost.OnKeyUp (KeyEventArgs e)
at System.Windows.UIElement.OnKeyUpThunk (Object sender, KeyEventArgs e)
at System.Windows.Input.KeyEventArgs.InvokeEventHandler (Delegate genericHandler, Object genericTarget)
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 (RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent (RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea ()
at System.Windows.Input.InputManager.ProcessInput (InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput (InputReport inputReport)
at System.Windows.Interop.HwndKeyboardInputProvider.ReportInput (IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey)
at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction (MSG & msg, Boolean & handled)
at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator (MSG & msg, ModifierKeys modifiers)
at System.Windows.Interop.HwndSource.OnPreprocessMessage (Object param)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall (Delegate callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen (Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl (DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
at System.Windows.Threading.Dispatcher.Invoke (DispatcherPriority priority, Delegate method, Object arg)
at System.Windows.Interop.HwndSource.OnPreprocessMessageThunk (MSG & msg, Boolean & handled)
at System.Windows.Interop.HwndSource.WeakEventPreprocessMessage.OnPreprocessMessage (MSG & msg, Boolean & handled)
at System.Windows.Interop.ThreadMessageEventHandler.Invoke (MSG & msg, Boolean & handled)
at System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage (MSG & msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl (DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame (DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run ()
at System.Windows.Application.RunInternal (Window window)
at System.Windows.Application.Run (Window window)
at System.Windows.Application.Run ()
As you can see, none of our codes are in the stack trace, so I have nothing to fix. Anyone have any ideas on possible workarounds?
Thanks for the help!