2017-10-07 06:49:57 +08:00
|
|
|
## Crash in Selector when removing an item from a custom INCC collection
|
|
|
|
|
|
|
|
### Scope
|
|
|
|
Minor
|
|
|
|
|
|
|
|
### Version Introduced
|
|
|
|
4.7
|
|
|
|
|
|
|
|
### Version Reverted
|
|
|
|
4.7.1
|
|
|
|
|
|
|
|
### Source Analyzer Status
|
|
|
|
NotPlanned
|
|
|
|
|
|
|
|
### Change Description
|
2018-02-13 06:46:07 +08:00
|
|
|
An `T:System.InvalidOperationException` can occur in the following scenario:
|
2017-10-07 06:49:57 +08:00
|
|
|
* The ItemsSource for a `T:System.Windows.Controls.Primitives.Selector` is a collection with a custom
|
|
|
|
implementation of `T:System.Collections.Specialized.INotifyCollectionChanged`.
|
|
|
|
* The selected item is removed from the collection.
|
|
|
|
* The `T:System.Collections.Specialized.NotifyCollectionChangedEventArgs` has
|
|
|
|
`P:System.Collections.Specialized.NotifyCollectionChangedEventArgs.OldStartingIndex` = -1
|
|
|
|
(indicating an unknown position).
|
|
|
|
|
|
|
|
The exception's callstack begins
|
|
|
|
at System.Windows.Threading.Dispatcher.VerifyAccess()
|
|
|
|
at System.Windows.DependencyObject.GetValue(DependencyProperty dp)
|
|
|
|
at System.Windows.Controls.Primitives.Selector.GetIsSelected(DependencyObject element)
|
|
|
|
|
2018-03-01 08:06:28 +08:00
|
|
|
This exception can occur in .NET Framework 4.5 if the application has more than one Dispatcher thread.
|
|
|
|
In .NET Framework 4.7 the exception can also occur in applications with a single Dispatcher thread.
|
|
|
|
The issue is fixed in .NET Framework 4.7.1.
|
2017-10-07 06:49:57 +08:00
|
|
|
|
|
|
|
- [ ] Quirked
|
|
|
|
- [ ] Build-time break
|
|
|
|
|
|
|
|
### Recommended Action
|
2018-03-01 08:06:28 +08:00
|
|
|
Upgrade to .NET Framework 4.7.1.
|
2017-10-07 06:49:57 +08:00
|
|
|
|
|
|
|
### Affected APIs
|
|
|
|
* Not detectable via API analysis
|
|
|
|
|
|
|
|
### Category
|
|
|
|
Windows Presentation Foundation (WPF)
|
|
|
|
|
|
|
|
<!--
|
|
|
|
### Original Bug
|
|
|
|
424259
|
|
|
|
-->
|
|
|
|
|
|
|
|
|