Error after selecting text in richtextbox
-
I am developing an application in C# and using richtextbox. After formatting the text when i select all the text it gives exception given below: See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box. ************** Exception Text ************** System.NullReferenceException: Object reference not set to an instance of an object. at RichTextEditor.Editor.ucEditor.rtbDoc_SelectionChanged(Object sender, EventArgs e) in E:\MDCENTERWINAPP\Editor\ucEditor.cs:line 841 at System.Windows.Forms.RichTextBox.OnSelectionChanged(EventArgs e) at System.Windows.Forms.RichTextBox.WmSelectionChange(SELCHANGE selChange) at System.Windows.Forms.RichTextBox.WmReflectNotify(Message& m) at System.Windows.Forms.RichTextBox.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) Any Suggestion...............
Do good and have good.
-
I am developing an application in C# and using richtextbox. After formatting the text when i select all the text it gives exception given below: See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box. ************** Exception Text ************** System.NullReferenceException: Object reference not set to an instance of an object. at RichTextEditor.Editor.ucEditor.rtbDoc_SelectionChanged(Object sender, EventArgs e) in E:\MDCENTERWINAPP\Editor\ucEditor.cs:line 841 at System.Windows.Forms.RichTextBox.OnSelectionChanged(EventArgs e) at System.Windows.Forms.RichTextBox.WmSelectionChange(SELCHANGE selChange) at System.Windows.Forms.RichTextBox.WmReflectNotify(Message& m) at System.Windows.Forms.RichTextBox.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) Any Suggestion...............
Do good and have good.
Hi, The message gives the location of the exception causing statement in the source code.
Silent Eagle wrote:
System.NullReferenceException: Object reference not set to an instance of an object. at RichTextEditor.Editor.ucEditor.rtbDoc_SelectionChanged(Object sender, EventArgs e) in E:\MDCENTERWINAPP\Editor\ucEditor.cs:line 841
If the error on line 841 is not obvious, set a breakpoint there and investigate further with the debugger. Alan.
-
I am developing an application in C# and using richtextbox. After formatting the text when i select all the text it gives exception given below: See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box. ************** Exception Text ************** System.NullReferenceException: Object reference not set to an instance of an object. at RichTextEditor.Editor.ucEditor.rtbDoc_SelectionChanged(Object sender, EventArgs e) in E:\MDCENTERWINAPP\Editor\ucEditor.cs:line 841 at System.Windows.Forms.RichTextBox.OnSelectionChanged(EventArgs e) at System.Windows.Forms.RichTextBox.WmSelectionChange(SELCHANGE selChange) at System.Windows.Forms.RichTextBox.WmReflectNotify(Message& m) at System.Windows.Forms.RichTextBox.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) Any Suggestion...............
Do good and have good.
Hi as Alan said, look at line 841. Read the Exception text, it is there to help you. Look in particular to the first line that mentions one of your filenames, and a line number. And tell Visual Studio to always show line numbers in edit windows (menu Tools/Options/TextEditor/AllLanguages...). :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.