dotnet/wpf · error · ArgumentException

SR.EPGuidNotFound

Error message

SR.EPGuidNotFound

What it means

DrawingAttributes stores standard properties (Color, StylusTip, Height, Width, etc.) in an ExtendedProperties collection keyed by GUID. GetExtendedPropertyBackedProperty throws this ArgumentException when the GUID is not present and no default value exists for it. It means you asked for an extended property that was never set.

Solutions

  1. Verify the GUID matches exactly the one used in AddPropertyData
  2. Check ContainsPropertyData(guid) or _extendedProperties.Contains before reading
  3. Handle ArgumentException and fall back to DrawingAttributes.GetDefaultDrawingAttributeValue(guid)

Example fix

// before
var v = attrs.GetPropertyData(myGuid);
// after
var v = attrs.ContainsPropertyData(myGuid) ? attrs.GetPropertyData(myGuid) : DrawingAttributes.GetDefaultDrawingAttributeValue(myGuid);
Defensive patterns

Strategy: validation

Validate before calling

if (attrs.ContainsPropertyData(guid)) { var v = attrs.GetPropertyData(guid); } else { var v = DrawingAttributes.GetDefaultDrawingAttributeValue(guid); }

Type guard

bool HasProperty(DrawingAttributes a, Guid g) => a.ContainsPropertyData(g);

Try / catch

try { v = attrs.GetPropertyData(guid); } catch (ArgumentException) { v = DrawingAttributes.GetDefaultDrawingAttributeValue(guid); }

Prevention

When it happens

Trigger: Calling GetExtendedPropertyBackedProperty (via DrawingAttributes property getters or GetExtendedProperty) with a GUID that is not in _extendedProperties and has no registered default value — e.g. a custom GUID never added via AddPropertyData.

Common situations: Typo'd or misremembered custom property GUIDs; reading property data from ink serialized on another platform that omitted the property; consuming third-party ink that lacks expected GUIDs.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/6f2091a268bf5d11. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Ink/DrawingAttributes.cs:943

                }
            }
        }

        /// <summary>
        /// All DrawingAttributes are backed by an ExtendedProperty
        /// this is a simple helper to set a property
        /// </summary>
        /// <param name="id">id</param>
        /// <returns></returns>
        private object GetExtendedPropertyBackedProperty(Guid id)
        {
            if (!_extendedProperties.Contains(id))
            {
                if (null != DrawingAttributes.GetDefaultDrawingAttributeValue(id))
                {
                    return DrawingAttributes.GetDefaultDrawingAttributeValue(id);
                }
                throw new ArgumentException(SR.EPGuidNotFound, nameof(id));
            }
            else
            {
                return _extendedProperties[id];
            }
        }

        /// <summary>
        /// A help method which fires INotifyPropertyChanged.PropertyChanged event
        /// </summary>
        /// <param name="e"></param>
        private void PrivateNotifyPropertyChanged(PropertyDataChangedEventArgs e)
        {
            if ( e.PropertyGuid == KnownIds.Color)
            {
                OnPropertyChanged(nameof(Color));
            }
            else if ( e.PropertyGuid == KnownIds.StylusTip)

View on GitHub (pinned to 81131a70a4)