question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Crash due to exception "Height must be non-negative."

See original GitHub issue
  • .NET Core Version: 4.8 and 4.8.1
  • Windows version: 22H2
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
  • Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc…)? No.

Problem description: Crash related to updating an ObservableCollection in WPF. Started occurring after recent application of update KB5017271. The issue was not occurring before this. Crashing has also been observed on Windows 10 machines, after the application of KB5017497. Our application has not been updated. Crash appears to be related to these .NET updates.

Actual behavior: Call stacks are all identical:

   at System.Windows.Size.set_Height(Double value)\r\n   
   at System.Windows.Controls.VirtualizingStackPanel.AdjustEffectiveOffsetForItemsChange(ItemsChangedEventArgs args)\r\n   
   at System.Windows.Controls.VirtualizingStackPanel.ShouldItemsChangeAffectLayoutCore(Boolean areItemChangesLocal, ItemsChangedEventArgs args)\r\n   
   at System.Windows.Controls.VirtualizingPanel.OnItemsChangedInternal(Object sender, ItemsChangedEventArgs args)\r\n   
   at System.Windows.Controls.Panel.OnItemsChanged(Object sender, ItemsChangedEventArgs args)\r\n   
   at System.Windows.Controls.ItemContainerGenerator.OnItemRemoved(Object item, Int32 itemIndex, NotifyCollectionChangedEventArgs collectionChangedArgs)\r\n   
   at System.Windows.Controls.ItemContainerGenerator.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)\r\n   
   at System.Windows.WeakEventManager.ListenerList`1.DeliverEvent(Object sender, EventArgs e, Type managerType)\r\n   
   at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)\r\n   
   at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)\r\n   
   at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)\r\n   
   at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)\r\n   
   at System.Windows.Controls.ItemCollection.OnViewCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)\r\n  
   at System.Windows.WeakEventManager.ListenerList`1.DeliverEvent(Object sender, EventArgs e, Type managerType)\r\n   
   at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)\r\n   
   at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)\r\n   
   at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)\r\n   
   at System.Windows.Data.ListCollectionView.ProcessCollectionChangedWithAdjustedIndex(NotifyCollectionChangedEventArgs args, Int32 adjustedOldIndex, Int32 adjustedNewIndex)\r\n   
   at System.Windows.Data.ListCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)\r\n   
   at System.Windows.Data.CollectionView.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)\r\n   
   at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1.RemoveItem(Int32 index)\r\n   
   

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
pchaurasia14commented, Nov 4, 2022

@billhenn - The issue has been fixed on .NET Framework and will be available in upcoming servicing updates.

2reactions
boydpattersoncommented, Jan 20, 2023

@dipeshmsft I can confirm the issue is no longer reproducible in our Sample Browser application on Win10 22H2 after applying the January .NET Framework update. Thank you for helping get this issue resolved!

Read more comments on GitHub >

github_iconTop Results From Across the Web

WPF - Width and Height must be non-negative
This is the exception I get: Width and Height must be non-negative. Stack trace here: at System.Windows.Size.
Read more >
ArgumentException: "Height must be non-negative" from ...
We got an ArgumentException:"Height must be non-negative"(please see the call stack below) while tree items were added to the collection.
Read more >
"Width and Height must be non-negative" exception is ...
Hi, After upgrading DevExpress from 13.1.7 to 13.1.8, an ArgumentException occurs with message "Width and Height must be non-negative".
Read more >
Management Client Crash During LPR configuration
Exception type: System.ArgumentException. Exception message: Width and Height must be non-negative. Exception target site: .ctor. at System.Windows.
Read more >
DataGrid exceptions on re-size the column width... - Mindscape
System.ArgumentException was unhandled Message=Width and Height must be non-negative. Source=WindowsBase StackTrace: at System.Windows.Size..
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found