dotnet/wpf · error · ArgumentException
The GUID is not part of the ExtendedPropertyCollection.
Error message
The GUID is not part of the ExtendedPropertyCollection.
What it means
ExtendedPropertyCollection.Remove(Guid) verifies the id exists via Contains(id) and throws ArgumentException(SR.EPGuidNotFound, nameof(id)) — 'The GUID is not part of the ExtendedPropertyCollection.' — when it does not. You can only remove a property whose GUID was previously added.
Solutions
- Check Contains(guid) before calling Remove and skip if absent.
- Track which ids were actually added (or diff collection contents) before cleanup passes.
- Catch ArgumentException named 'id' and treat it as a no-op when best-effort removal is intended.
- Keep the set of valid property GUIDs in sync with the data that created them (single source of truth).
Example fix
// before
properties.Remove(guid); // ArgumentException if not present
// after
if (properties.Contains(guid))
{
properties.Remove(guid);
} Defensive patterns
Strategy: validation
Validate before calling
if (properties.Contains(id))
properties.Remove(id); Type guard
static bool IsRemovable(ExtendedPropertyCollection c, Guid id) => c.Contains(id);
Try / catch
try { properties.Remove(id); }
catch (ArgumentException ex) when (ex.ParamName == "id") { /* not present: treat as no-op */ } Prevention
- Always guard Remove with Contains
- Track ids actually added by your pipeline
- Keep known property-GUID lists in sync across app versions
When it happens
Trigger: Calling Remove(guid) with a GUID never added to the collection, or after it was already removed; PersistExtendedProperties processing stale ids from a saved configuration or schema that no longer matches the ink data.
Common situations: Removing a well-known application property (e.g. a drawing-attribute GUID) from strokes that never had it; double-deletion in cleanup code; ids drifting between app versions so persisted ids no longer exist on loaded ink.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- Property not set.
- ExtendedProperty is already part of the…
- GUID cannot be empty.
- InvalidMatrixContainsInfinity
- InvalidMatrixContainsNaN
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/f721622e4a9a84cb.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/ExtendedPropertyCollection.cs:168
throw new ArgumentException(SR.EPExists, nameof(id));
}
ExtendedProperty extendedProperty = new ExtendedProperty(id, value);
//this will raise change events
this.Add(extendedProperty);
}
/// <summary>
/// Remove
/// </summary>
/// <param name="id">id</param>
internal void Remove(Guid id)
{
if (!Contains(id))
{
throw new ArgumentException(SR.EPGuidNotFound, nameof(id));
}
ExtendedProperty propertyToRemove = GetExtendedPropertyById(id);
System.Diagnostics.Debug.Assert(propertyToRemove != null);
_extendedProperties.Remove(propertyToRemove);
//
// this value is bogus now
//
_optimisticIndex = -1;
// fire notification event
if (this.Changed != null)
{
ExtendedPropertiesChangedEventArgs eventArgs
= new ExtendedPropertiesChangedEventArgs(propertyToRemove, null);
this.Changed(this, eventArgs);View on GitHub (pinned to 81131a70a4)