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

ScrollBarValueChanged NullReferenceException

1 Answer 55 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 26 Oct 2012, 11:37 AM
Hi,

I seem to get a NullReferenceException from time to time when I assisigning the ScrollBarValueChanged event. It doesn't always throw the exception, and I can't quite work out how this is happening.
this.radRichTextBox.VerticalScrollBar.ValueChanged += radRichTextBox_ScrollBarValueChanged;


I assigned it in my RadRichTextbox loaded event:
private void radRichTextBox_Loaded(object sender, RoutedEventArgs e)
{
            //Set ListBoxItems
            AutoCompleteSetListBoxItems(1);
            //Set Autocomplete ListBox itemssource
            radListBox.ItemsSource = autoCompleteListItems;
 
            //Assign DocumentArranged event. This will in turn enable document changed event.
            this.radRichTextBox.DocumentArranged += radRichTextBox_DocumentArranged;
 
            //Assign CommandExecuting Event. This will catch cut, copy, paste etc
            this.radRichTextBox.CommandExecuting += radRichTextBox_CommandExecuting;
 
            //Assign Scroll Event To Reposition Popup AutoComplete Window
            this.radRichTextBox.VerticalScrollBar.ValueChanged += radRichTextBox_ScrollBarValueChanged;
}



Here's the stack trace:

   at TAS2.RadRichTextBoxAutoComplete.radRichTextBox_Loaded(Object sender, RoutedEventArgs e) in C:\TAS2 - Q3 2012\TAS2\RadRichTextBoxAutoComplete.xaml.cs:line 195
   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(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
   at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
   at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
   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)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at System.Threading.ExecutionContext.runTryCode(Object userData)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(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)
   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at System.Windows.Application.Run()
   at TAS2.App.Main() in C:\TAS2 - Q3 2012\TAS2\obj\x86\Debug\App.g.cs:line 0



System.Reflection.RuntimeMethodInfo:
{Void radRichTextBox_Loaded(System.Object, System.Windows.RoutedEventArgs)}


Has anyone come across this error before?

Thanks for your time,

Rob

1 Answer, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 29 Oct 2012, 03:35 PM
Hello Rob,

We tried reproducing the exception you are observing, unfortunately to no avail. Can you please try to isolate the issue in a sample runnable project and send it to us in a support ticket, so we can further investigate it.

Thank you in advance!
 
Kind regards,
Petya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
RichTextBox
Asked by
Robert
Top achievements
Rank 1
Answers by
Petya
Telerik team
Share this question
or