NullReferenceException in Document.OffsetToPosition

SyntaxEditor for Windows Forms Forum

Posted 16 years ago by Adam Dickinson
Version: 4.0.0262
Platform: .NET 2.0
Environment: Windows XP (32-bit)
Avatar
Here's another one relating to the closing/disposing of a Document/SyntaxEditor instance. A user was closing a bunch of documents in quick succession.

System.NullReferenceException: Object reference not set to an instance of an object.
at ActiproSoftware.SyntaxEditor.Document.OffsetToPosition(Int32 offset)
at ActiproSoftware.SyntaxEditor.Selection.get_EndDocumentPosition()
at ragScriptEditor.Form1.editor_GotFocus(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnGotFocus(EventArgs e)
at ActiproSoftware.SyntaxEditor.SyntaxEditor.OnGotFocus(EventArgs e)
at System.Windows.Forms.Control.WmSetFocus(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at ActiproSoftware.SyntaxEditor.SyntaxEditor.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)

The release notes for 4.0.270 mentions a fix to a disposed SyntaxEditor, but since this bug happens so randomly, it's hard for me to say if it is fixed in the latest version or not.

Lucky for me, it's my own code that is trying to access the EndDocumentPosition property, so I am able to test for this failure case and avoid the exception myself.

Thanks.

Comments (2)

Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Thanks, I've added code to that method to do a null check (in case it has been disposed) but you may get an invalid position back accordingly so your check is still a good thing to keep in place.


Actipro Software Support

Posted 16 years ago by Adam Dickinson
Avatar
No, thank you.
The latest build of this product (v24.1.0) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.