Every so often, users report this error. It is from Infragistics.WPF4.Controls.Menus.XamDataTree 14.2. It looks like there is an internal error happening in the XamDataTree, but I (so Far) haven't been able to reproduce it. What does this stack trace mean? Every time i run the offending process, it works fine.
System.NullReferenceException: Object reference not set to an instance of an object.
at Infragistics.Controls.Menus.IntermediateNodesManager.get_DataCount()
at Infragistics.Controls.Menus.NodesManager.Infragistics.IProvideDataItems<Infragistics.Controls.Menus.XamDataTreeNode>.get_DataCount()
at Infragistics.Collections.BindableItemCollection`1.GetCount()
at Infragistics.Collections.CollectionBaseEnumerator`1.System.Collections.IEnumerator.MoveNext()
at Infragistics.AutomationPeers.XamDataTreeNodeAutomationPeer.GetChildrenCore()
at System.Windows.Automation.Peers.AutomationPeer.EnsureChildren()
at System.Windows.Automation.Peers.AutomationPeer.UpdateChildrenInternal(Int32 invalidateLimit)
at System.Windows.Automation.Peers.AutomationPeer.UpdateChildren()
at Infragistics.AutomationPeers.XamDataTreeNodeAutomationPeer.Node_PropertyChanged(Object sender, PropertyChangedEventArgs e)
at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
at Infragistics.DependencyObjectNotifier.OnPropertyChanged(String propertyName)
at Infragistics.Controls.Menus.XamDataTreeNode.OnElementReleased(XamDataTreeNodeControl element)
at Infragistics.DependencyObjectRecyclingContainer`1.Infragistics.ISupportRecycling.OnElementReleased(FrameworkElement elem)
at Infragistics.RecyclingManager.PanelInfo.ReleaseElement(ISupportRecycling obj)
at Infragistics.Controls.Menus.Primitives.NodesPanel.ReleaseNode(XamDataTreeNode node, Boolean removeManager)
at Infragistics.Controls.Menus.Primitives.NodesPanel.ResetNodes(Boolean releaseAll)
at Infragistics.Controls.Menus.XamDataTree.XamDataTree_Unloaded(Object sender, RoutedEventArgs e)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
at System.Windows.BroadcastEventHelper.BroadcastUnloadedEvent(Object root)
at MS.Internal.LoadedOrUnloadedOperation.DoWork()
at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
Wanted to note i recently went from
Version=14.2.20142.1000 to
InfragisticsWPF4.Controls.Menus.XamDataTree.v14.2, Version=14.2.20142.2024
It was never reported prior to this upgrade...
Hi Travis,
AutomationPeer stuff usually means some kind of screen reading is going on with the application. Some program on the users machine is trying to screen read the application. Programs like Microsoft's Narrator do this.
Did your users provide any steps for reproducing this? I understand that you are currently not able to reproduce this but I would like to know what exactly your users were doing with the XamDataTree at the time of the exception. I see that the XamDataTree Unloaded event was fired. Was the user changing screens or something which caused the XamDataTree to unload?
The UserControl class allows you to override the OnCreateAutomationPeer method so you should be able to use the code I included above inside the UserControl.
It would really be good if I had a sample that reproduced the issue so I can log this right away, but if that is not possible then I can ask the developers to take a look at the call stack and see if there is anything that can be done to the code.
I will keep you updated.
Maybe looking at some of my code will help you figure out the problem, i have attached the relevant classes, controls etc. The classes and controls are included, and i just stuck in the methods that call them in the .txt file.
I found an eerily similar issue here: http://ko.infragistics.com/community/forums/t/91777.aspx?PageIndex=1
Has this been "fixed" in the version i am using?
(InfragisticsWPF4.Controls.Menus.XamDataTree.v14.2, Version=14.2.20142.2024)
Perhaps the problem has been reintroduced?
The last part of the call stack in that forum thread looks the same and the issue described in that thread is supposed to be resolved in the version you are using. There is a slight difference though in that the call stack does not show the issue stemming from unloading the tree. So it's entirely possible this is a separate issue brought about by different consequences.
I sent the call stack to our development team for them to take a look. I explained to them that in your application the issue occurs when closing the XamDataTree window. (this is pretty obvious in the call stack with the Unloaded event). I will let you know what they say.
Thanks Rob. I was finally able to create a sample that reproduces the problem (when Narrator is running and works fine when Narrator is OFF). It doesn't make a lot sense, but it shows the issue. On close, the collection that is bound to the XamDataTree was being cleared inside a dispatcher. I still don't understand why this always worked fine before. OR why running Microsoft Narrator causes it to throw the null exsception. However, commenting out the clearing of the collection solved the error from occurring. This still leaves the question of why Narrator causes a problem in the XamDataTree control. I believe this may be a bug and should be addressed. I have uploaded the project so you may confirm the issue. Let me know your findings and if there is a resolution. Thanks again for your continued assistance.
Hi Michael,
Do you have a private support case already open for this? If so, you can give me the number and I'll link your case to the dev issue as well.
Following this, as I have also raised a support issue on this, but couldn't reliably reproduce.
Yeah, that was an error on my part. Sorry about that. In the excitement of obtaining a reproducible sample I didn't read through what you said clearly enough. Thanks for setting me straight.
Yes, i will can use my workaround in the meantime. It is actually commenting out the .Clear of the collection for the workaround. So the fix is to NOT clear it, I believe you erroneously stated above the fix was to clear it, it is just the opposite. If you look in the sample i provided, there are comments in the ConfirmClose method in CompareBillingVM.cs, you will find a comment '
//this ClearAll method is the offender, commenting it out fixes the problem'
commenting out that line allows the code to run without the exception. Inside of ClearAll(), the bound collection is cleared inside a dispatcher.
Thanks again, I am looking forward to a resolution.
Thanks to your sample I was able to reproduce the exception exactly. Since I have reproduced the issue now I have created a private case for you so that I can link the logged development issue to the case so you can view the status of it. The case number is CAS-147911-Z2W3T8 and the development issue ID is 186133. You can view the case here.
You mentioned that if you clear the collection the issue no longer occurs. Is this a workaround you can use in your application in the mean time?