EditorView._1 Null reference?

SyntaxEditor for Windows Forms Forum

Posted 14 years ago by NSXDavid
Avatar
Occasionally when setting the text of the document, I get the following exception (and the sytnax editor renders thereafter with a big red X):

"Object reference not set to an instance of an object."
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)

The circumstances are that the user was editing some code and had to do a 3-way merge via an external tool. On exit of the external tool it reads in the happily merged text and sets the syntaxeditor's document text to this new data. Every so often it just blows up in this manner when doing that.

I presume _2 and _2 method names are the result of obfuscation of the symbols?

-- David

Comments (6)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hmmm... there's a lot of code in the procedure that is calling so I can't really tell where that's happening without debugging it.

Can you try and isolate what causes it and either post how to duplicate it in the sample app (best option) or send us a sample project of your own that demonstrates it? That would help immensely.

Yes the obfuscation causes those symbols.


Actipro Software Support

Posted 14 years ago by NSXDavid
Avatar
Unfortunately, no... it won't reproduce at will. <IMG SRC="frown.gif" border="0"> Anyway to get a debug version or something, I can try and make it happen and catch it.

-- David
Posted 14 years ago by Craig Neblett
Avatar
This may not be it but every time I've had a null reference in or related to paint code the problem has always been threading. I'd check InvokeRequired prior to setting the text.
Posted 14 years ago by NSXDavid
Avatar
InvokeRequired? I must have missed something in .NET class. What's that?

-- David
Posted 14 years ago by Craig Neblett
Avatar
InvokeRequired will be set to true when the current thread is different from the UI thread. IIRC, this is an advanced method so you may need to turn off the 'Hide Advanced Members' option in tools/options/text editor/your language. If you call control properties/methods from a thread other than the one that created them you will eventually get an error similar to the one you are seeing. In the example below from one of my applications SerialPortExecute is called from a thread other than the UI thread. Therefore, an Invoke is required to return to the UI thread before I can interact with any UI elements.


Private Delegate Sub SerialPortDelegate(ByVal port As PortConfiguration)

Private Sub SerialPortExecute(ByVal sender As Object, ByVal e As EventArgs)
If Me.InvokeRequired Then
Dim args As Object() = {CType(sender, PortConfiguration)}
Dim del As New SerialPortDelegate(AddressOf Me.SerialPortRead)
Me.Invoke(del, args)
Else
Me.SerialPortRead(CType(sender, PortConfiguration))
End If
End Sub

Private Sub SerialPortRead(ByVal port As PortConfiguration)
'Access UI controls here
End Sub
Posted 14 years ago by NSXDavid
Avatar
Thanks for the heads-up... I think the issue is that I needed to set the SynchronizingObject on my process object so when the event that the process has exited comes back it is on the correct thread. Giving that a try.

-- David
The latest build of this product (v2018.1 build 0341) was released 6 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.