Issue with KB5017262 & KB5017270 cause WPF application to crash

Tamir Cohen 1 Reputation point
2022-09-28T16:42:51.953+00:00

Hello,

we are having a trouble since the September cumulative update,

our customers reporting that since the upgrade of the above KB, our WPF application crash with the below error:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at System.Windows.Controls.VirtualizingStackPanel.UpdateExtent(Boolean areItemChangesLocal)
at System.Windows.Controls.VirtualizingStackPanel.ShouldItemsChangeAffectLayoutCore(Boolean areItemChangesLocal, ItemsChangedEventArgs args)
at System.Windows.Controls.VirtualizingPanel.OnItemsChangedInternal(Object sender, ItemsChangedEventArgs args)
at System.Windows.Controls.Panel.OnItemsChanged(Object sender, ItemsChangedEventArgs args)
at System.Windows.Controls.ItemContainerGenerator.OnItemAdded(Object item, Int32 index, NotifyCollectionChangedEventArgs collectionChangedArgs)
at System.Windows.Controls.ItemContainerGenerator.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
at System.Windows.WeakEventManager.ListenerList1.DeliverEvent(Object sender, EventArgs e, Type managerType) at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args) at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e) at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args) at System.Windows.WeakEventManager.ListenerList1.DeliverEvent(Object sender, EventArgs e, Type managerType)
at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
at System.Windows.Data.ListCollectionView.ProcessCollectionChangedWithAdjustedIndex(NotifyCollectionChangedEventArgs args, Int32 adjustedOldIndex, Int32 adjustedNewIndex)
at System.Collections.ObjectModel.ObservableCollection1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) at System.Collections.ObjectModel.ObservableCollection1.InsertItem(Int32 index, T item)
at WPFComponents.ViewModels.TraceViewModel.Add(TraceItem traceItem)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Delegate.DynamicInvokeImpl(Object[] args)
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)

our application is .Net 4.6.2, and uninstalling KB5017262 seems to "fix" the issue

we need help on this ASAP, we are encounter massive surge in our customer support department with this crash.

thanks,

Tamir

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,616 questions
Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,671 questions
{count} votes

3 answers

Sort by: Most helpful
  1. B Rabinovich 1 Reputation point
    2022-10-02T07:04:21.503+00:00

    I also have the same problem.
    The problem occurs because I use the flag IsVirtualizingStackPanel_45Compatible which is intended to fix a performance problem, as described in https://social.msdn.microsoft.com/Forums/vstudio/en-US/c04c07de-883c-4801-ae24-0dd75f2ffe20/performance-issue-for-virtualizingstackpanel-in-net-461?forum=wpf
    When the ListView/DataGrid contains enough items so that the scrollBar is displayed, any attempt to add another item causes a crash.
    I created a small project that reproduces the problem: https://github.com/br25802580/ListView_Crash_KB5017270
    This is the code that causes the problem to be reproduced:

    XAML

    <StackPanel Orientation="Vertical" Margin="40">  
            <Button HorizontalAlignment="Left" Click="AddItemBtn_Click">Add item</Button>  
            <ListView Grid.Row="2" x:Name="MyList"  
                      HorizontalAlignment="Left"  
                      Width="200"  
                      MaxHeight="60">  
            </ListView>  
     </StackPanel>  
    

    XAML.cs

            public MainWindow()  
            {  
                InitializeComponent();  
      
                MyList.Items.Add("111");  
                MyList.Items.Add("222");  
                MyList.Items.Add("333");  
                MyList.Items.Add("444");  
            }  
      
            private void AddItemBtn_Click(object sender, RoutedEventArgs e)  
            {  
                MyList.Items.Add("555");  
            }  
    

    App.config

      <appSettings>  
        <add key="IsVirtualizingStackPanel_45Compatible" value="true" />  
      </appSettings>  
    
    0 comments No comments

  2. Limitless Technology 39,351 Reputation points
    2022-10-04T08:24:21.99+00:00

    Hello there,

    As these issues are caused by the updates you can collect the Event logs and share them with the Microsft team to get this sorted or get an appropriate workaround for this.
    -Download the Debug Diagnostics Tool or process monitor tool.

    • Get a dump from the crashing process and share it through the feedback hub.

    Process Monitor is an advanced monitoring tool for Windows that shows real-time file system, Registry and process/thread activity. You can get the tool from here https://learn.microsoft.com/en-us/sysinternals/downloads/procmon

    You can raise feedback to the Microsoft team. The Feedback Hub app lets you tell Microsoft about any problems you run into https://support.microsoft.com/en-us/windows/send-feedback-to-microsoft-with-the-feedback-hub-app-f59187f8-8739-22d6-ba93-f66612949332


    --If the reply is helpful, please Upvote and Accept it as an answer–

    0 comments No comments

  3. Paul Steiner 1 Reputation point
    2022-10-24T11:16:29.967+00:00

    We face a similar problem related to this patch.
    For a print preview we add items to a listview and update the layout, every time we add an item. This way we detect when the page is full and a new page needs to be added.
    This code works for over ten years for hundreds of customers.
    Since the Windows Update KB5017262 it does not work. We tried many times. When we deinstall the update, it works. If we reapply the update, it does not work.

    This is just pseudo code but it shows, what we do:

    while (pageUserControl.lasrRow.ActualHeight > distance)  
    {  
    pageUserControl.Positions.Add(viewModel);  
    pageUserControl.UpdateLayout();  
    }  
    

    Without the windows update, the actualHeight changes when UpdateLayout is called. With the update, the ActualHeight does not change.

    0 comments No comments