Null reference exception when SyntaxEditor.Document.SetHeaderAndFooterText method called.

SyntaxEditor for WPF Forum

Posted 5 years ago by Sreeram Akella
Version: 14.2.0611
Platform: .NET 4.5
Environment: Windows 8 (64-bit)
Avatar

Hi,

We are using Actipro Syntax Editor v14.2.610.0 in one of our products with VB.Net Language addon. Recently, we found a null reference exception while calling SetHeaderAndFooter method of ActiproSoftware.Text.Implementation.EditorDocument class.

This crash is specific to Windows 8.1 with touch interface (in our case Surface pro 3) or Window 7 (with a running instance of UI Automation client, like Narrator). Found a similar bug on other (Non Actipro ) WPF controls which use ItemAutomationPeer, http://www.telerik.com/forums/radpaneautomationpeer-getnamecore-error 

Can we expect a fix for this in the next release? Or do you have a work around ?

Thanks,

Ram.

---------------- Stack trace --------------------

Below is the stack trace,

System.NullReferenceException was unhandled by user code
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=PresentationFramework
StackTrace:
at System.Windows.Automation.Peers.ItemAutomationPeer.GetNameCore()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.ContextLayoutManager.fireAutomationEvents()
at System.Windows.ContextLayoutManager.UpdateLayout()
at System.Windows.UIElement.UpdateLayout()
at ActiproSoftware.Windows.Controls.SyntaxEditor.Primitives.EditorView.OnViewLineLayoutManagerLayoutRequired(Object sender, EventArgs e)
at #m3b.#c4b.#Ekc(ITextSnapshot #I7b, ITextChange #g7b)
at ActiproSoftware.Windows.Controls.SyntaxEditor.Primitives.TextView.#Ekc(ITextSnapshot #I7b, ITextChange #g7b)
at ActiproSoftware.Windows.Controls.SyntaxEditor.Implementation.EditorViewManager.#ZE.#pqc(Object #axf)
at #O2b.#N2b.#Kec[#gi](DependencyObject #QOd, Action'1 #2vf, #gi #3vf)
at ActiproSoftware.Windows.Controls.SyntaxEditor.Implementation.EditorViewManager.NotifyDocumentTextChanged(TextSnapshotChangedEventArgs #yhb)
at ActiproSoftware.Windows.Controls.SyntaxEditor.SyntaxEditor.OnDocumentTextChanged(Object sender, TextSnapshotChangedEventArgs e)
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)

[Modified 5 years ago]

Comments (3)

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

Hello,

The stack trace you show here has the exception being raised from deep in Microsoft code so it's a bit different from the other example you linked to, since in that case, the exception occurred directly in their code.  This case seems like it might be a bug in the .NET framework.

Do you have a new simple sample project that you could make and email to our support address so we could try it on our Surface Pro 3?  If so, please reference this thread and tell the steps to repro it.  Also be sure to rename the .zip file extension so it doesn't get spam blocked.  Thanks!


Actipro Software Support

Posted 5 years ago by Sreeram Akella
Avatar

Hi,


Thanks for the quick reply.


From what I understood after going through various forums, this crash might happen when an ItemAutomationPeer class is used in a custom control. Here is another link that describes a very similar issue and solution, 

http://stackoverflow.com/questions/16245732/nullreferenceexception-from-presentationframework-dll

Also, we are using other Actipro controls like Docking control, Property Grid and editors, along with Syntax Editor and VB.Net Add-on in the same project. So at the moment I am not very sure of the problematic control. However, I am trying to reproduce this issue in a sample project and I'll share it very soon.

Also, please take a look at this full stack trace.


Thanks,
Ram.


--------------- Full Stack trace. ------------------------------------------
System.NullReferenceException was unhandled by user code
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=PresentationFramework
StackTrace:
at System.Windows.Automation.Peers.ItemAutomationPeer.GetNameCore()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
at System.Windows.ContextLayoutManager.fireAutomationEvents()
at System.Windows.ContextLayoutManager.UpdateLayout()
at System.Windows.UIElement.UpdateLayout()
at ActiproSoftware.Windows.Controls.SyntaxEditor.Primitives.EditorView.OnViewLineLayoutManagerLayoutRequired(Object sender, EventArgs e)
at #m3b.#c4b.#Ekc(ITextSnapshot #I7b, ITextChange #g7b)
at ActiproSoftware.Windows.Controls.SyntaxEditor.Primitives.TextView.#Ekc(ITextSnapshot #I7b, ITextChange #g7b)
at ActiproSoftware.Windows.Controls.SyntaxEditor.Implementation.EditorViewManager.#ZE.#pqc(Object #axf)
at #O2b.#N2b.#Kec[#gi](DependencyObject #QOd, Action'1 #2vf, #gi #3vf)
at ActiproSoftware.Windows.Controls.SyntaxEditor.Implementation.EditorViewManager.NotifyDocumentTextChanged(TextSnapshotChangedEventArgs #yhb)
at ActiproSoftware.Windows.Controls.SyntaxEditor.SyntaxEditor.OnDocumentTextChanged(Object sender, TextSnapshotChangedEventArgs e)
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 Omron.Cxap.Modules.DeviceHmi.PageElements.Views.Editors.ExpressionEditor.SetHeaderAndFooter()
at Omron.Cxap.Modules.DeviceHmi.PageElements.Views.Editors.ExpressionEditor.HeaderOrFooterChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at ActiproSoftware.Windows.Controls.SyntaxEditor.SyntaxEditor.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)
at System.Windows.Data.BindingExpressionBase.Invalidate(Boolean isASubPropertyChange)
at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
at System.Windows.Data.BindingExpression.ScheduleTransfer(Boolean isASubPropertyChange)
at MS.Internal.Data.ClrBindingWorker.NewValueAvailable(Boolean dependencySourcesChanged, Boolean initialValue, Boolean isASubPropertyChange)
at MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)
at MS.Internal.Data.PropertyPathWorker.OnDependencyPropertyChanged(DependencyObject d, DependencyProperty dp, Boolean isASubPropertyChange)
at MS.Internal.Data.ClrBindingWorker.OnSourceInvalidation(DependencyObject d, DependencyProperty dp, Boolean isASubPropertyChange)
at System.Windows.Data.BindingExpression.HandlePropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args)
at System.Windows.Data.BindingExpressionBase.OnPropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args)
at System.Windows.Data.BindingExpression.OnPropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args)
at System.Windows.DependentList.InvalidateDependents(DependencyObject source, DependencyPropertyChangedEventArgs sourceArgs)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
at System.Windows.Controls.ItemContainerGenerator.UnlinkContainerFromItem(DependencyObject container, Object item, IGeneratorHost host)
at System.Windows.Controls.ItemContainerGenerator.RemoveAllInternal(Boolean saveRecycleQueue)
at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.RemoveAll()
at System.Windows.Controls.ItemContainerGenerator.OnRefresh()
at System.Windows.Controls.ItemContainerGenerator.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
at System.Windows.WeakEventManager.ListenerList'1.DeliverEvent(Object sender, EventArgs e, Type managerType)
at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
at System.Windows.Controls.ItemCollection.SetCollectionView(CollectionView view)
at System.Windows.Controls.ItemCollection.ClearItemsSource()
at System.Windows.Controls.ItemsControl.OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.ClearValueCommon(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata)
at System.Windows.DependencyObject.ClearValue(DependencyProperty dp)
at ActiproSoftware.Windows.Controls.PropertyGrid.Primitives.PropertyGridDataAccessorItem.SetItemsSource(Object data)
at ActiproSoftware.Windows.Controls.PropertyGrid.Primitives.PropertyGridDataAccessorItem.<UpdateItemsSourceWorker>b__7(IList'1 d)
at ActiproSoftware.Windows.Controls.PropertyGrid.Primitives.PropertyGridDataAccessorItem.UpdateItemsSourceWorker(Object obj)
at ActiproSoftware.Windows.Controls.PropertyGrid.Primitives.PropertyGridDataAccessorItem.Cleanup()
at ActiproSoftware.Windows.Controls.PropertyGrid.Primitives.PropertyGridDataAccessorItem.Cleanup()
at ActiproSoftware.Windows.Controls.PropertyGrid.PropertyGrid.ClearContainerForItemOverride(DependencyObject element, Object item)
at System.Windows.Controls.ItemsControl.MS.Internal.Controls.IGeneratorHost.ClearContainerForItem(DependencyObject container, Object item)
at System.Windows.Controls.ItemContainerGenerator.UnlinkContainerFromItem(DependencyObject container, Object item, IGeneratorHost host)
at System.Windows.Controls.ItemContainerGenerator.RemoveAllInternal(Boolean saveRecycleQueue)
at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.RemoveAll()
at System.Windows.Controls.ItemContainerGenerator.OnRefresh()
at System.Windows.Controls.ItemContainerGenerator.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
at System.Windows.WeakEventManager.ListenerList'1.DeliverEvent(Object sender, EventArgs e, Type managerType)
at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
at System.Windows.Controls.ItemCollection.SetCollectionView(CollectionView view)
at System.Windows.Controls.ItemCollection.SetItemsSource(IEnumerable value, Func'2 GetSourceItem)
at System.Windows.Controls.ItemsControl.OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
at System.Windows.Data.BindingOperations.SetBinding(DependencyObject target, DependencyProperty dp, BindingBase binding)
at System.Windows.FrameworkElement.SetBinding(DependencyProperty dp, BindingBase binding)
at ActiproSoftware.Windows.Controls.PropertyGrid.PropertyGrid.SetItemsSource(Object data)
at ActiproSoftware.Windows.Controls.PropertyGrid.PropertyGrid.<>c__DisplayClass1a.<UpdateItemsSourceWorker>b__19(IList'1 d)
at ActiproSoftware.Windows.Controls.PropertyGrid.PropertyGrid.UpdateItemsSourceWorker(Object obj)
at ActiproSoftware.Windows.Controls.PropertyGrid.PropertyGrid.UpdateItemsSource()
at ActiproSoftware.Windows.Controls.PropertyGrid.PropertyGrid.AutoUpdateItemsSource()
at ActiproSoftware.Windows.Controls.PropertyGrid.PropertyGrid.OnSelectedObjectsPropertyValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)
at System.Windows.Data.BindingExpressionBase.Invalidate(Boolean isASubPropertyChange)
at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
at System.Windows.Data.BindingExpression.ScheduleTransfer(Boolean isASubPropertyChange)
at MS.Internal.Data.ClrBindingWorker.NewValueAvailable(Boolean dependencySourcesChanged, Boolean initialValue, Boolean isASubPropertyChange)
at MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)
at MS.Internal.Data.ClrBindingWorker.OnSourcePropertyChanged(Object o, String propName)
at MS.Internal.Data.PropertyPathWorker.OnPropertyChanged(Object sender, PropertyChangedEventArgs e)
at System.Windows.WeakEventManager.ListenerList'1.DeliverEvent(Object sender, EventArgs e, Type managerType)
at System.ComponentModel.PropertyChangedEventManager.OnPropertyChanged(Object sender, PropertyChangedEventArgs args)
at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
at Omron.Cxap.PresentationLayer.ViewModel.ViewModelBase.OnPropertyChanged(Boolean commitChanges, String[] propertyNames)
at Omron.Cxap.PresentationLayer.ViewModel.ViewModelBase.SetValue[TValue](TValue& valueToSet, TValue newValue, Boolean commitChanges, String[] propertyNames)
at Omron.Cxap.PresentationLayer.ViewModel.ViewModelBase.SetValue[TValue](TValue& valueToSet, TValue newValue, String propertyName)
at Omron.Cxap.Modules.DeviceHmi.PropertyGrid.Core.PropertyGridViewModelBase.SetNewAndClearOld(Tuple'2 rootAndSelectedItems)
at Omron.Cxap.Modules.DeviceHmi.PropertyGrid.Core.PropertyGridViewModelBase.<BeginUpdate>b__7(Task'1 t)
at System.Threading.Tasks.ContinuationTaskFromResultTask'1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
InnerException:

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

That article is a good find.  It sounds like there is indeed a problem in the core WPF framework related to this that we might be able to work around if we can debug the problem and determine which control it's happening on.  Are you able to determine which control the peer is for?

And if you can make the simple sample and send that to us per the instructions in our previous post, that would be ideal so that we can repro it here.  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.