Posted 19 years ago by painetraine
Avatar
I am getting the following exception when opening a window with a SE control on it:

Top Level Exception
Type: System.NullReferenceException
Message: Object reference not set to an instance of an object.
Source: ActiproSoftware.SyntaxEditor
Stack Trace: at ActiproSoftware.SyntaxEditor.EditorView._1(Graphics , Rectangle , DocumentLine , Int32 , DisplayLine , _56 , Rectangle , Int32 )
at ActiproSoftware.SyntaxEditor.EditorView._2(Graphics , Rectangle )
at ActiproSoftware.SyntaxEditor.EditorView.OnRender(PaintEventArgs e)
at ActiproSoftware.WinUICore.UIElement.Render(PaintEventArgs e)
at ActiproSoftware.WinUICore.UIControl.OnRenderChildElements(PaintEventArgs e)
at ActiproSoftware.WinUICore.UIControl.Render(PaintEventArgs e)
at ActiproSoftware.WinUICore.UIControl._1(PaintEventArgs )
at ActiproSoftware.WinUICore.UIControl.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at ActiproSoftware.SyntaxEditor.SyntaxEditor.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

This is for v158

Any ideas on why I might be getting this and if it is something I can fix/handle?

Thanks

Comments (4)

Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hmmm... Not sure what woud cause that. Can you create a small project that duplicates it and email it to us so we can debug?


Actipro Software Support

Posted 19 years ago by painetraine
Avatar
I am still trying to dup this on my side since it happens with a user. However, I got a similar but slightly different error from a different user:

Top Level Exception
Type: System.ArgumentOutOfRangeException
Message: Index was out of range. Must be non-negative and less
than the size of the collection.
Parameter name: index
Source: mscorlib
Stack Trace: at System.Collections.ArrayList.get_Item(Int32 index)
at ActiproSoftware.SyntaxEditor.DisplayLineCollection.get_Item(Int32
index)
at ActiproSoftware.SyntaxEditor.EditorView._2(Graphics , Rectangle
)
at ActiproSoftware.SyntaxEditor.EditorView.OnRender(PaintEventArgs
e)
at ActiproSoftware.WinUICore.UIElement.Render(PaintEventArgs e)
at
ActiproSoftware.WinUICore.UIControl.OnRenderChildElements(PaintEventArgs
e)
at ActiproSoftware.WinUICore.UIControl.Render(PaintEventArgs e)
at ActiproSoftware.WinUICore.UIControl._1(PaintEventArgs )
at ActiproSoftware.WinUICore.UIControl.OnPaint(PaintEventArgs e)
at
System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e,
Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at ActiproSoftware.SyntaxEditor.SyntaxEditor.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam)

I am trying to think if I've added anything new and the only thing I can think of is that I now add LexicalPatterns to Groups on a separate thread from the main UI thread. I basically thread off loading some items from the database and then essentially do something similar to the following:

Document.Language.IsUpdating = true;
Group.Clear();
Group.Add(new LexPatt("Placeholder"));
foreach (Item from Database)
Group.Add(new LexPatt());
Document.Language.IsUpdating = false;

Any ideas what would cause the above exception? The user did mention that he saw the text in the editor briefly and then a big red X appeared where the control was and he received this message???

Thanks,

Ashton
Posted 19 years ago by painetraine
Avatar
Something else that might help:

Roughly about the time the error occurred, there was a problem trying to set IsUpdating = false after adding some LexicalPatterns to a group:

the code in the method is structured as such

method ()
{
this.Document.Language.IsUpdating = true;

try {...}
finally
{
try
{
if (this.Document != null && this.Document.Language != null)
this.Document.Language.IsUpdating = false;
}
catch (Exception ex)
{
...
}
}
}

In the finally, the if statement or IsUpdating change threw a "Object reference not set to an instance of an object." Since I check for a valid doc and then for a valid lang on the valid doc, it must have occurred when I called IsUpdating = false. The catch block assumes that there were some invalid tokens added and basically resets the group, so it would clear out the tokens, add only the initial token defined in the xml lang file back in and then set isupdating back to false.

Thanks,

Ashton
Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
I'm thinking that it's a threading issue since you are changing things on a separate thread but the main thread is trying to access objects that you have removed.


Actipro Software Support

The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.