dotnet/wpf · error · ArgumentException
SR.InvalidGuid
Error message
SR.InvalidGuid
What it means
StrokeCollection.GetPropertyData throws ArgumentException when propertyDataId equals Guid.Empty. Custom stroke properties are keyed by a non-empty Guid identifier; Guid.Empty is never a valid property key in the ink ExtendedProperties store. The library rejects it immediately to prevent an unresolvable property lookup.
Solutions
- Ensure the property Guid is a real generated identifier; assign it via new Guid("...") or a const Guid and verify it is not Guid.Empty before calling GetPropertyData.
- Add a guard in the caller: if (propertyDataId == Guid.Empty) throw/log before calling GetPropertyData.
- If the Guid originates from parsed input, use Guid.TryParse/Exactlyn and reject empty results.
Example fix
// before
var value = strokes.GetPropertyData(someGuid); // someGuid is Guid.Empty
// after
if (someGuid == Guid.Empty)
throw new InvalidOperationException("Property GUID was not initialized");
var value = strokes.GetPropertyData(someGuid); Defensive patterns
Strategy: validation
Validate before calling
if (propertyDataId == Guid.Empty)
throw new ArgumentException("Property data GUID must be a non-empty Guid", nameof(propertyDataId));
// safe to call:
var value = strokes.GetPropertyData(propertyDataId); Type guard
static bool IsValidPropertyId(Guid id) => id != Guid.Empty;
Try / catch
try { return strokes.GetPropertyData(id); }
catch (ArgumentException ex) when (ex.ParamName == "propertyDataId") { return null; } Prevention
- Store property GUIDs as readonly static readonly Guid constants so they cannot default to Guid.Empty.
- Never consume the result of an unvalidated Guid.Parse/TryParse.
- Initialize Guid fields at declaration or in the constructor.
When it happens
Trigger: Calling StrokeCollection.GetPropertyData(Guid.Empty). Typically happens when the Guid came from an uninitialized field, a default(Guid) struct, or a failed Guid.TryParse whose result was used anyway.
Common situations: Developers storing/retrieving custom metadata (e.g. author name, drawing attributes) on ink strokes pass a Guid field that was never assigned; serializing/deserializing property IDs from config where the empty string parsed to Guid.Empty.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Drawing Attribute tag embedded in ISF stream does not match…
- Duplicate ApplicationGesture values are not allowed.
- Global Custom Attribute tag embedded in ISF stream does not…
- GUID cannot be empty.
- If AllGestures is specified, it must be the only…
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/bcc797ccd97560a8.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Ink/StrokeCollection.cs:187
/// </summary>
/// <param name="propertyDataId"></param>
public void RemovePropertyData(Guid propertyDataId)
{
object propertyData = GetPropertyData(propertyDataId);
this.ExtendedProperties.Remove(propertyDataId);
// fire notification
OnPropertyDataChanged(new PropertyDataChangedEventArgs(propertyDataId, null, propertyData));
}
/// <summary>
/// Allows retrieval of objects from the EPC
/// </summary>
/// <param name="propertyDataId"></param>
public object GetPropertyData(Guid propertyDataId)
{
if ( propertyDataId == Guid.Empty )
{
throw new ArgumentException(SR.InvalidGuid, nameof(propertyDataId));
}
return this.ExtendedProperties[propertyDataId];
}
/// <summary>
/// Allows retrieval of a Array of guids that are contained in the EPC
/// </summary>
public Guid[] GetPropertyDataIds()
{
return this.ExtendedProperties.GetGuidArray();
}
/// <summary>
/// Allows the checking of objects in the EPC
/// </summary>
/// <param name="propertyDataId"></param>
public bool ContainsPropertyData(Guid propertyDataId)View on GitHub (pinned to 81131a70a4)