This is a migrated thread and some comments may be shown as answers.

Object reference error in "UpdateCaretStyle"

1 Answer 112 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Desh
Top achievements
Rank 1
Desh asked on 05 Mar 2018, 11:52 AM

Hello! Team,

We have a WPF window in which we're using multiple RichTextBoxes (RTB). We encountered an object reference error while editing text in one of the rtb. Stack trace log attached.

Date Time : 2/27/2018 2:22:12 PM ,
User Name : XXXXXXXX,
NameSpace : Telerik.Windows.Documents.UI ,
Class Name : Telerik.Windows.Documents.UI.DocumentWebLayoutPresenter ,
Method Name : UpdateCaretStyle ,
Exception Message : Object reference not set to an instance of an object. ,
Error Trace :    at Telerik.Windows.Documents.UI.DocumentWebLayoutPresenter.UpdateCaretStyle()
   at Telerik.Windows.Documents.UI.DocumentWebLayoutPresenter.UpdateCaretSize()
   at Telerik.Windows.Documents.UI.DocumentWebLayoutPresenter.DoOnCaretLocationChanged()
   at Telerik.Windows.Documents.Utils.SuspendChangingAndChangedActionCounter.InvokeChangedActionInternal()
   at Telerik.Windows.Documents.Utils.SuspendChangingAndChangedActionCounter.InvokeChanged()
   at Telerik.Windows.Documents.DocumentPosition.OnLocationChanged(Boolean changesCursorInitialLocation)
   at Telerik.Windows.Documents.DocumentPosition.CallOnPositionChanged(Boolean changesCursorInitialLocation)
   at Telerik.Windows.Documents.Selection.MouseSelectionHandler.SetDocumentPosition(DocumentPosition documentPosition, Point position, Boolean moveToNextIfOutOfBox)
   at Telerik.Windows.Documents.Selection.MouseSelectionHandler.RegisterDocumentMouseDown(Boolean ctrlPressed, Boolean shiftPressed, Point position, UIElement originalSource, SourceType source)
   at Telerik.Windows.Documents.UI.DocumentPresenterBase.HandleMouseLeftButtonDownOnPosition(Point position, UIElement originalSource, SourceType source)
   at Telerik.Windows.Documents.UI.DocumentPresenterBase.Owner_MouseLeftButtonDown(Object sender, MouseButtonEventArgs e)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   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.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, WindowMessage 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, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler) Inner Exception:
SourceFilePath: c:\Builds\13\AppPath\App.xaml.cs

 

RTB configuration:

<telerik:RadRichTextBox x:Name="txtContent" IsFocusable="True" PreviewKeyDown="txtContent_PreviewKeyDown"
                         AutomationProperties.AutomationId="{Binding TagValue,StringFormat=Comment_{0},RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"
                         BorderThickness="0" BorderBrush="White" IsSpellCheckingEnabled="True"
                         DocumentInheritsDefaultStyleSettings="True"
                         GotFocus="txtContent_GotFocus" LostFocus="txtContent_LostFocus"
                         DocumentContentChanged="txtContent_DocumentContentChanged"
                         HorizontalContentAlignment="Left"  IsContextMenuEnabled="True"         
                         MouseLeave="txtContent_MouseLeave"
                         PreviewMouseRightButtonDown="txtContent_PreviewMouseRightButtonDown"
                         KeyDown="txtContent_KeyDown"
                         Background="Transparent" FontFamily="Georgia (Body)"
                         IsSelectionMiniToolBarEnabled="False"
                         AcceptsReturn="True" ScrollViewer.VerticalScrollBarVisibility="Auto"
                         ScrollViewer.HorizontalScrollBarVisibility="Auto" Tag="{Binding TagValue}"
                         MouseMove="txtContent_MouseMove" >
</telerik:RadRichTextBox>

 

Another issue with this exception is that we're not able to isolate exact steps to reproduce the issue.

As is seen in the logs the exception is not coming from any of our custom methods, its coming from some inbuild dll method of telerik. So, please suggest what could be causing this issue.

 

Regards

Tushar

1 Answer, 1 is accepted

Sort by
0
Tanya
Telerik team
answered on 06 Mar 2018, 09:36 AM
Hello Tushar,

Looking at the stack trace of the exception seems like it is thrown when the user clicks somewhere in the control. However, I am afraid that I cannot tell what is causing the error from the provided information. The implementation of UpdateCaretStyle() uses the presenter's Owner property of type RadRichTextBox and its CurrentSpanStyle but unfortunately, I cannot say which one and why it would be null. Furthermore, the issue might also depend on the content in the control. 

I also tested several sample scenarios but couldn't reproduce the error. If you are observing it on your end, could you please share a document which we can use to perform further tests? 

Regards,
Tanya
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
RichTextBox
Asked by
Desh
Top achievements
Rank 1
Answers by
Tanya
Telerik team
Share this question
or