dotnet/wpf · error · InvalidOperationException
throw new…
Error message
throw new InvalidOperationException(SR.Format(SR.MemberNotAllowedForView, "Remove"));
What it means
CollectionViewProxy.Remove(item) forwards to the proxied view's IEditableCollectionView.Remove. If the wrapped view does not implement that interface (null `ecv` at CollectionViewProxy.cs:579), the proxy throws InvalidOperationException because the view cannot remove items.
Solutions
- Verify support via ProxiedView as IEditableCollectionView (or CanRemove) before calling Remove
- Mutate the underlying collection directly and rely on INotifyCollectionChanged to refresh the view
- Back the binding with a collection type whose default view implements IEditableCollectionView
Example fix
// before
proxy.Remove(selectedItem);
// after
if (proxy.CanRemove)
{
proxy.Remove(selectedItem);
} Defensive patterns
Strategy: validation
Validate before calling
if (!proxy.CanRemove) return; proxy.Remove(item);
Type guard
bool SupportsRemove(CollectionViewProxy p) => p?.ProxiedView is IEditableCollectionView;
Try / catch
try { proxy.Remove(item); }
catch (InvalidOperationException ex) when (ex.Message.Contains("Remove")) { ((IList)sourceCollection).Remove(item); } Prevention
- Prefer mutating the source collection directly for maximum compatibility
- Check CanRemove / cast ProxiedView as IEditableCollectionView first
- Document which view types your view-model requires
When it happens
Trigger: Calling Remove on a CollectionViewProxy wrapping a view without IEditableCollectionView support (read-only source collections, custom views).
Common situations: Deleting the selected row in a ItemsControl bound to a non-editable collection; migrating from ObservableCollection to a custom/immutable source; view-model code that assumes all views support Remove.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/0dceae711e55a7ba.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Data/CollectionViewProxy.cs:579
else
{
throw new InvalidOperationException(SR.Format(SR.MemberNotAllowedForView, "RemoveAt"));
}
}
/// <summary>
/// Remove the given item from the underlying collection.
/// </summary>
void IEditableCollectionView.Remove(object item)
{
IEditableCollectionView ecv = ProxiedView as IEditableCollectionView;
if (ecv != null)
{
ecv.Remove(item);
}
else
{
throw new InvalidOperationException(SR.Format(SR.MemberNotAllowedForView, "Remove"));
}
}
#endregion Removing items
#region Transactional editing of an item
/// <summary>
/// Begins an editing transaction on the given item. The transaction is
/// completed by calling either <seealso cref="IEditableCollectionView.CommitEdit"/> or
/// <seealso cref="IEditableCollectionView.CancelEdit"/>. Any changes made to the item during
/// the transaction are considered "pending", provided that the view supports
/// the notion of "pending changes" for the given item.
/// </summary>
void IEditableCollectionView.EditItem(object item)
{
IEditableCollectionView ecv = ProxiedView as IEditableCollectionView;
if (ecv != null)View on GitHub (pinned to 81131a70a4)