Unhandled exception: SpanIndicatorLayer.Clear

SyntaxEditor for Windows Forms Forum

Posted 16 years ago by Stephen Curle
Avatar
I occasionally get the following error shortly after displaying text in the editor. I am not able to handle the error and it causes the app to crash. I'm using version 4.0.276.0.

"Object reference not set to an instance of an object."

at ActiproSoftware.SyntaxEditor.SpanIndicatorLayer.Clear()
at ActiproSoftware.SyntaxEditor.SpanIndicatorLayerCollection.Remove(SpanIndicatorLayer layer)
at ActiproSoftware.SyntaxEditor.SyntaxLanguage.a(Document A_0)
at ActiproSoftware.SyntaxEditor.SyntaxLanguage.a(Document A_0, EventArgs A_1)
at ActiproSoftware.SyntaxEditor.Document.a(ISemanticParseData A_0, TextRange A_1, Boolean A_2, Object A_3)
at ActiproSoftware.SyntaxEditor.Document.ActiproSoftware.SyntaxEditor.ISemanticParseDataTarget.NotifySemanticParseComplete(SemanticParserServiceRequest request)
at ActiproSoftware.SyntaxEditor.SemanticParserService.a(SemanticParserServiceRequest A_0)
at ActiproSoftware.SyntaxEditor.SemanticParserService.c()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Comments (5)

Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Stephen,

We haven't seen that happen. Can you make a simple sample project that shows it and email it over so we can debug the issue? Thanks!


Actipro Software Support

Posted 16 years ago by Stephen Curle
Avatar
I haven't managed to reproduce this with a simple project.

Not sure if this will help identify the problem but I occassionally get an exception which I am able to handle when SyntaxEditor.Document.SpanIndicatorLayer.Clear is called ('object reference not set').

I've checked that the SyntaxEditor.Document and SyntaxEditor.SpanIndicator instances are not Nothing. Interestingly if I move the execution point to re-execute the Clear method while in debug mode the exception isn't thrown a second time.

Have you absolutely no idea at all what might cause this or how to prevent the Clear method throwing an exception ??
Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Stephen,

The only things that could raise that exception in that method are a null Document property on the layer, a null Document.Lines value, or if one of the indicator items in the layer was null instead of a valid span indicator instance.

You could probably check these things in your exception handler to see which one it is. None of those should ever occur though, which is why I was asking if you could make a repro.


Actipro Software Support

Posted 16 years ago by Stephen Curle
Avatar
I've managed to reproduce this now with a simple example. If you add the syntax editor to a form and use the code below as code behind for the form (assumed to contain a button called Button1) and then launch the form and click Button1 (which simply sets the Document.Text property and then calls SpanIndicatorLayers.Clear) then you should get an exception (you may need to click a few times as it occurs at random). This problem doesn't occur if you remove the comment from the line 'HeaderText &= "Public Class qwe" & vbCrLf'

Imports ActiproSoftware.SyntaxEditor
Imports System.Collections.Generic

Public Class Form1

Private dotNetProjectResolver As New ActiproSoftware.SyntaxEditor.Addons.DotNet.Dom.DotNetProjectResolver()

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
SemanticParserService.Start()
dotNetProjectResolver.CachePath = IO.Path.GetDirectoryName(Application.ExecutablePath) + "\Cache\"
dotNetProjectResolver.AddExternalReferenceForSystemAssembly("System")
dotNetProjectResolver.AddExternalReferenceForSystemAssembly("System.Collections")
dotNetProjectResolver.AddExternalReferenceForMSCorLib()
editor1.Document.SemanticParsingEnabled = True
editor1.Document.Language = New ActiproSoftware.SyntaxEditor.Addons.VB.VBSyntaxLanguage
editor1.Document.LanguageData = dotNetProjectResolver
editor1.Document.Filename = "Hello"
editor1.Document.AutoCaseCorrectEnabled = True
editor1.Document.Outlining.Mode = ActiproSoftware.SyntaxEditor.OutliningMode.Automatic
Dim HeaderText As String = "Imports System, System.Math" & vbCrLf
'HeaderText &= "Public Class qwe" & vbCrLf
editor1.Document.HeaderText = HeaderText '"Namespace qwe" '& vbCrLf & "End Namespace"
'editor1.Document.FooterText = vbCrLf & "End Class" '& vbCrLf & "End Namespace"
End Sub

Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
SemanticParserService.Stop()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
editor1.Document.Text = "Return qweqweqweasdas"
editor1.Document.SpanIndicatorLayers.Clear()
End Sub

End Class
Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Stephen,

Thanks for the sample, I've updated our code to resolve the issue for the next maintenance release.


Actipro Software Support

The latest build of this product (v24.1.1) 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.