SetHeaderAndFooterText throws an exception

SyntaxEditor for WPF Forum

Posted 5 years ago by Aernout van Groen
Version: 13.2.0591
Platform: .NET 4.0
Environment: Windows Server 2008 (64-bit)
Avatar

Hi,

When I set the footer- and header-text with SetHeaderAndFooterText I am receiving an exception:

Editor.Document.SetHeaderAndFooterText("script{ $text = \"", "\"; }");

Object reference not set to an instance of an object.

at ActiproSoftware.Windows.Controls.SyntaxEditor.Outlining.Implementation.OutliningManager.#Ugc(IOutliningSource #ql, TextSnapshotRange #Ayf)
at ActiproSoftware.Windows.Controls.SyntaxEditor.Outlining.Implementation.OutliningManager.#0gc(Nullable'1 #Cyf, TextSnapshotRange #Ayf, Boolean #Dyf)
at ActiproSoftware.Windows.Controls.SyntaxEditor.Outlining.Implementation.OutliningManager.OnDocumentTextChanged(Object #xhb, TextSnapshotChangedEventArgs #yhb)
at ActiproSoftware.Text.Implementation.TextDocumentBase.OnTextChanged(TextSnapshotChangedEventArgs e)
at ActiproSoftware.Text.Implementation.CodeDocument.OnTextChanged(TextSnapshotChangedEventArgs e)
at ActiproSoftware.Text.Implementation.TextDocumentBase.SetHeaderAndFooterText(String headerText, String footerText)
at IamConsole.View.WorkflowDocument.TextDataItemView.OnInitialized(EventArgs e)

 

After inspecting the header and footer afterwards, the header and footer appear to have the correct values:

((ActiproSoftware.Text.Implementation.TextDocumentBase)(Editor.Document)).CurrentSnapshot.HeaderText == "script{ $text = \""

 

Simply ignoring the exception seems to work for me, but I would like to prevent this from happening.

 

Regards,
Aernout

Comments (1)

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Aernout,

When you use header/footer text, it will effectively create a virtualized snapshot where the offsets extend past the ranges of the real snapshot, since the header/footer text is concatenated with the document body.  But outside of parsing, those offsets will be out of range.  That might be what's going on here.

Normally you wouldn't want your outlining source to add nodes for offsets that are outside the snapshot.  That would likely help prevent this.  If you'd like to make a new simple sample project that shows it happening, you can email that to our support address and we can debug it to try and guard against this case better without having it throw an exception too.  Please reference this thread and rename the .zip file extension of anything you send.  Thanks!


Actipro Software Support

The latest build of this product (v2019.1 build 0683) 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.