WPF RichTextBox Control

  • Thread starter Thread starter Anthony Meehan
  • Start date Start date
A

Anthony Meehan

Hi,

We've got a WinForms application which uses a WPF Rich Text Box (via
WindowsFormsIntegration) which is failing on certain user's machines, but
works fine on all others. If we clear their NT profile (we use roaming
profiles), the issue goes away. Of course this is not a suitable workaround
for a large number of users.

To ensure it wasn't any other components causing the issue, I created a
simple application that just has the WPF RichTextBox within a WinForms
application and the same exception occurs for the users which can't use our
main application.

The exception is as below. Any help would be appreciated.


Thanks.

NullReferenceException: Object reference not set to an instance of an object.

Stacktrace
at System.Windows.Documents.TextStore.OnGotFocus()
at System.Windows.Documents.TextEditor.OnGotKeyboardFocus(Object sender,
KeyboardFocusChangedEventArgs e)
at
System.Windows.Controls.Primitives.TextBoxBase.OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
at System.Windows.UIElement.OnGotKeyboardFocusThunk(Object sender,
KeyboardFocusChangedEventArgs e)
at
System.Windows.Input.KeyboardFocusChangedEventArgs.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.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)
at System.Windows.Input.KeyboardDevice.Focus(IInputElement element)
at System.Windows.UIElement.Focus()
at System.Windows.Documents.TextEditorMouse.MoveFocusToUiScope(TextEditor
This)
at System.Windows.Documents.TextEditorMouse.OnMouseDown(Object sender,
MouseButtonEventArgs e)
at
System.Windows.Controls.Primitives.TextBoxBase.OnMouseDown(MouseButtonEventArgs e)
at System.Windows.UIElement.OnMouseDownThunk(Object sender,
MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.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.ContentElement.RaiseEventImpl(RoutedEventArgs args)
at System.Windows.ContentElement.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.HwndMouseInputProvider.ReportInput(IntPtr hwnd,
InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y,
Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd,
Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32
msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam,
IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
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 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr
wParam, IntPtr lParam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run()
at xxx.xxx.xxx.Program.Main(String[] args) in d:\xxx\Program.cs:line 135
 
Hi,

We've got a WinForms application which uses a WPF Rich Text Box (via
WindowsFormsIntegration) which is failing on certain user's machines, but
works fine on all others. If we clear their NT profile (we use roaming
profiles), the issue goes away. Of course this is not a suitable workaround
for a large number of users.

To ensure it wasn't any other components causing the issue, I created a
simple application that just has the WPF RichTextBox within a WinForms
application and the same exception occurs for the users which can't use our
main application.

The exception is as below. Any help would be appreciated.

It looks like a genuine bug, and it's probably best to report it to VS
Connect, and possibly contact Microsoft directly if you need urgent
resolution:

https://connect.microsoft.com/VisualStudio/Feedback
 
Back
Top