Can you help us solve crashes in DataGrid WPF?

Anonymous
2024-02-13T14:11:50+00:00

We are experiencing crashes in particular environments on customer sites in our WPF application.

  • The callstack points to the DataGrid control, which contains in these cases CheckBoxes which are ToggleButtons (callstack).
    • Our codebase extends the DataGrid control but has been untouched since 2016
  • For some users of a particular customer this reproduces instantly and for others sometimes. Internally we don't have a repro nor do other customers crash.
  • We don't formally support Automation in our WPF application but these customers may use Automation on their system nonetheless.

I've searched around and I found very similair callstacks originating from other controls than ToggleButton. From what I understand have these been fixed in .NET updates:

Callstack (Originally in Dutch)

System.ArgumentNullException: Value cannot be null. Parameter name: item
    at System.Windows.Automation.Peers.DataGridItemAutomationPeer..ctor(Object item, DataGridAutomationPeer dataGridPeer)
    at System.Windows.Automation.Peers.DataGridAutomationPeer.CreateItemAutomationPeer(Object item)
    at System.Windows.Automation.Peers.ItemsControlAutomationPeer.GetChildrenCore()
    at System.Windows.Automation.Peers.DataGridAutomationPeer.GetChildrenCore()
    at System.Windows.Automation.Peers.AutomationPeer.EnsureChildren()
    at System.Windows.Automation.Peers.AutomationPeer.GetChildren()
    at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
    at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
    at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
    at System.Windows.Automation.Peers.AutomationPeer.ValidateConnected(AutomationPeer connectedPeer)
    at MS.Internal.Automation.ElementProxy.StaticWrap(AutomationPeer peer, AutomationPeer referencePeer)
    at System.Windows.Automation.Peers.AutomationPeer.ProviderFromPeer(AutomationPeer peer)
    at System.Windows.Automation.Peers.AutomationPeer.RaisePropertyChangedEvent(AutomationProperty property, Object oldValue, Object newValue)
    at System.Windows.Automation.Peers.ToggleButtonAutomationPeer.RaiseToggleStatePropertyChangedEvent(Nullable`1 oldValue, Nullable`1 newValue)
    at System.Windows.Controls.Primitives.ToggleButton.OnIsCheckedChanged(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 System.Windows.Data.BindingOperations.ClearBinding(DependencyObject target, DependencyProperty dp)
    at MyNameSpace.MyDataGridCellValue.BindCellValue(DataGridCell cell, FrameworkElement el)
 in MyDataGridCellValue.cs:line 186
    at MyDataGridCellValue.BindCellProperties(DataGridCell cell, FrameworkElement el)
 in MyDataGridCellValue.cs:line 173
    at MyNamespace.MyDataGrid.OnLoadingRow(DataGridRow dgRow)
 in MyDataGrid.cs:line 1515
    at MyNamespace.MyDataGrid.OnLoadingRow(DataGridRowEventArgs e)
 in MyDataGrid.cs:line 1279
    at System.Windows.Controls.DataGrid.PrepareContainerForItemOverride(DependencyObject element, Object item)
    at System.Windows.Controls.ItemsControl.MS.Internal.Controls.IGeneratorHost.PrepareItemContainer(DependencyObject container, Object item)
    at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.PrepareItemContainer(DependencyObject container)
    at System.Windows.Controls.VirtualizingStackPanel.InsertContainer(Int32 childIndex, UIElement container, Boolean isRecycled)
    at System.Windows.Controls.VirtualizingStackPanel.AddContainerFromGenerator(Int32 childIndex, UIElement child, Boolean newlyRealized, Boolean isBeforeViewport)
    at System.Windows.Controls.VirtualizingStackPanel.MeasureChild(IItemContainerGenerator& generator, IContainItemStorage& itemStorageProvider, IContainItemStorage& parentItemStorageProvider, Object& parentItem, Boolean& hasUniformOrAverageContainerSizeBeenSet, Double& computedUniformOrAverageContainerSize, Double& computedUniformOrAverageContainerPixelSize, Boolean& computedAreContainersUniformlySized, Boolean& hasAnyContainerSpanChanged, IList& items, Object& item, IList& children, Int32& childIndex, Boolean& visualOrderChanged, Boolean& isHorizontal, Size& childConstraint, Rect& viewport, VirtualizationCacheLength& cacheSize, VirtualizationCacheLengthUnit& cacheUnit, Boolean& foundFirstItemInViewport, Double& firstItemInViewportOffset, Size& stackPixelSize, Size& stackPixelSizeInViewport, Size& stackPixelSizeInCacheBeforeViewport, Size& stackPixelSizeInCacheAfterViewport, Size& stackLogicalSize, Size& stackLogicalSizeInViewport, Size& stackLogicalSizeInCacheBeforeViewport, Size& stackLogicalSizeInCacheAfterViewport, Boolean& mustDisableVirtualization, Boolean isBeforeFirstItem, Boolean isAfterFirstItem, Boolean isAfterLastItem, Boolean skipActualMeasure, Boolean skipGeneration, Boolean& hasBringIntoViewContainerBeenMeasured, Boolean& hasVirtualizingChildren)
    at System.Windows.Controls.VirtualizingStackPanel.MeasureOverrideImpl(Size constraint, Nullable`1& lastPageSafeOffset, List`1& previouslyMeasuredOffsets, Nullable`1& lastPagePixelSize, Boolean remeasure)
    at System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(Size constraint)
    at System.Windows.Controls.Primitives.DataGridRowsPresenter.MeasureOverride(Size constraint)
    at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
    at System.Windows.UIElement.Measure(Size availableSize)
    at System.Windows.ContextLayoutManager.UpdateLayout()
    at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
    at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
    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 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
Windows Server Windows desktop and shell experience

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question. To protect privacy, user profiles for migrated questions are anonymized.

0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Anonymous
    2024-02-14T01:49:02+00:00

    Hello

    Thank you for posting in Microsoft Community forum!

    Based on the description, I understand your question is related to Windows Presentation Foundation (WPF).

    Since there are no engineers dedicated to this topic in this forum, in order to be able to get a quick and effective handling of your issue, I recommend that you repost your question in Stack Overflow or Microsoft Q&A, they are designed for developers.

    Thank you for your understanding and support. If you have any question or concern, please feel free to let us know.

    Have a nice day!

    Best Regards,

    Wesley Li

    0 comments No comments
  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  3. Anonymous
    2024-02-14T09:21:10+00:00
    0 comments No comments