dotnet/wpf · error · ArgumentException
InvalidGuid
Error message
InvalidGuid
What it means
Thrown by ExtendedPropertySerializer.Validate when an extended property is registered with Guid.Empty as its identifier. Every extended property must carry a real, unique GUID so ISF can key it; an empty GUID is meaningless and cannot be serialized or matched on load.
Solutions
- Supply a valid, non-empty Guid when adding the extended property (use Guid.NewGuid() or a fixed application GUID).
- Check where the GUID originates — fix parsing of the GUID string (Guid.TryParse) so it cannot silently become Guid.Empty.
- If the property is optional, skip adding it when no valid id is available.
Example fix
// before stroke.ExtendedProperties.Add(Guid.Empty, 42); // after Guid id = Guid.NewGuid(); // or a fixed application-specific GUID stroke.ExtendedProperties.Add(id, 42);
Defensive patterns
Strategy: validation
Validate before calling
Guid id = parsedViaTryParse ?? Guid.NewGuid();
if (id == Guid.Empty) throw new ArgumentException("Extended property id must be a non-empty Guid"); Type guard
bool IsValidPropertyId(Guid id) => id != Guid.Empty;
Try / catch
try { props.Add(id, value); }
catch (ArgumentException ex) when (ex.ParamName == "id") { Log.Error("Extended property id was Guid.Empty", ex); } Prevention
- Use Guid.TryParse instead of new Guid(string) so failures don't yield Guid.Empty
- Define extended property GUIDs as compile-time constants
- Never default missing GUID config to Guid.Empty
When it happens
Trigger: Calling Add on Stroke.ExtendedProperties / DrawingAttributes.ExtendedProperties with an empty Guid as the id, or InvokeValidateAsISF paths that pass Guid.Empty.
Common situations: Building extended property identifiers from parsed config or metadata where the GUID string failed to parse and defaulted to Guid.Empty; copy-paste code that forgot to set the id.
Related errors
- Global Custom Attribute tag embedded in ISF stream does not…
- Drawing Attribute tag embedded in ISF stream does not match…
- GUID cannot be empty.
- InvalidValueType
- InvalidValueType1
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/e7d055a866f08084.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/CustomAttributeSerializer.cs:773
{
guids[count++] = attribute.Id;
}
}
return guids;
}
#region Key/Value pair validation helpers
/// <summary>
/// Validates the data to be associated with a ExtendedProperty id
/// </summary>
/// <param name="id">ExtendedProperty identifier</param>
/// <param name="value">data</param>
/// <remarks>Ignores Ids that are not known (e.g. ExtendedProperties)</remarks>
internal static void Validate(Guid id, object value)
{
if (id == Guid.Empty)
{
throw new ArgumentException(SR.InvalidGuid);
}
if (id == KnownIds.Color)
{
if (!(value is System.Windows.Media.Color))
{
throw new ArgumentException(SR.Format(SR.InvalidValueType, typeof(System.Windows.Media.Color)), nameof(value));
}
}
// int attributes
else if (id == KnownIds.CurveFittingError)
{
if (!(value.GetType() == typeof(int)))
{
throw new ArgumentException(SR.Format(SR.InvalidValueType, typeof(int)), nameof(value));
}
}
else if (id == KnownIds.DrawingFlags)View on GitHub (pinned to 81131a70a4)