IndexOutOfRangeException in SyntaxEditor

SyntaxEditor for Windows Forms Forum

Posted 10 years ago by Joachim Schwieren

a customer using our product which uses SyntaxEditor reported the following exception. It seams to appear randomly and the stack trace shows that there is no direct link to our code...

Exception (System.IndexOutOfRangeException: Array Index out of bounds.
bei a5.b(Int32 A_0)
bei g.a(Int32 A_0)
bei ActiproSoftware.SyntaxEditor.DisplayLineCollection.e(Int32 A_0)
bei ActiproSoftware.SyntaxEditor.EditorView.OffsetToPosition(Int32 offset)
bei ActiproSoftware.SyntaxEditor.Selection.a(Int32 A_0, Int32 A_1, Int32 A_2)
bei ActiproSoftware.SyntaxEditor.Selection.get_EndEditPosition()
bei ActiproSoftware.SyntaxEditor.EditorView.j()
bei ActiproSoftware.SyntaxEditor.EditorView.f()
bei ActiproSoftware.SyntaxEditor.SyntaxEditor.OnGotFocus(EventArgs e)
bei System.Windows.Forms.Control.WmSetFocus(Message& m)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.ScrollableControl.WndProc(Message& m)
bei ActiproSoftware.SyntaxEditor.SyntaxEditor.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam))

Do you have an idea why this one happens? There is no clear way to reproduce it, it happens accidently...

EDIT: The customer told me that the exception occurs when he tries to load a binary file (e.g. an SWF file in his case); this does not make much sense because SyntaxEditor is a text editor but is there any change to prevent this or to raise a warning when a binary file is loaded into the control?



[Modified at 11/08/2011 07:36 AM]

Comments (3)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Joachim,

Which version are you using... is it the latest? I believe we did have a report of an issue with binary files a while back and corrected it then.

If you try the latest and that doesn't fix it, then please send us a file that repros the issue, and the instructions on how to make it occur. Thanks!

Actipro Software Support

Posted 10 years ago by Joachim Schwieren

sorry for the late reply. We did not manage to reproduce the error but we keep on getting this exception frequently from customers through our integrated exception reporting system. Customers say that they were just navigating with the cursor in the text, so nothing special at all.

Maybe you can have a look at the stack trace (and the obfuscated methods) in order to find a possible reason for this exception.

It looks like that some indices of a range are set to invalid values. Maybe you can catch this exception or check for invalid values before executing the method that throws this exception.

Thanks for your help and best regards,

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Joachim,

The methods that possibly are being called there are rather large so it's difficult to know where and in what scenario this is happening.

We really need to find some way to reproduce it so that we can sort out where it's coming from and then verify that it's fixed once we make a code change. It's not a good idea for UI components to catch exceptions because that can mask issues that need fixing (and could therefore show up elsewhere).

In the meantime you can inherit SyntaxEditor and do a try...catch around the OnGotFocus override. But we really would need you to try and make a new simple sample project that shows this error happening since we haven't seen it before. There is some sequence of events and configuration setup that make it occur. If you can figure that sequence out, you should be able to reliably repro it.

By the way, do you do things with multi-threading, such as modifying portions of SyntaxEditor from a separate thread? I wonder if something like that could be the culprit here?

Actipro Software Support

The latest build of this product (v21.1.0) was released 11 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.