dotnet/wpf · error · ArgumentException
GUID cannot be empty.
Error message
GUID cannot be empty.
What it means
The internal ExtendedProperty constructor requires a non-empty Guid identifying the ink attribute; Guid.Empty is rejected with ArgumentException(SR.InvalidGuid, 'GUID cannot be empty.'). Extended properties are keyed by GUID, so an empty id would create an unaddressable entry.
Solutions
- Supply a valid, non-empty Guid (e.g. a known ApplicationGuid or a newly generated Guid.NewGuid()) when adding the property.
- Check `id == Guid.Empty` before calling Add and skip or substitute a real id.
- Fix upstream data so the GUID is preserved through serialization/deserialization.
- If the guid was meant to be generated, replace default(Guid)/new Guid() placeholders with Guid.NewGuid().
Example fix
// before properties.Add(Guid.Empty, value); // ArgumentException: GUID cannot be empty. // after Guid id = knownAttributeId != Guid.Empty ? knownAttributeId : Guid.NewGuid(); properties.Add(id, value);
Defensive patterns
Strategy: validation
Validate before calling
if (id == Guid.Empty)
throw new ArgumentException("A valid non-empty GUID is required.", nameof(id));
properties.Add(id, value); Type guard
static bool IsValidPropertyId(Guid id) => id != Guid.Empty;
Try / catch
try { properties.Add(id, value); }
catch (ArgumentException) { /* Guid.Empty id: fix the source of the guid */ } Prevention
- Never use default(Guid) as a placeholder
- Validate guids at data-deserialization boundaries
- Generate ids with Guid.NewGuid() when none exists
When it happens
Trigger: Constructing ExtendedProperty(Guid.Empty, value), or calling ExtendedPropertyCollection.Add(Guid.Empty, value), which forwards to this constructor.
Common situations: Loading ISF/ink data where a property GUID was lost or zeroed; deserializing hand-built ink XML with placeholder GUIDs; using default(Guid) as a placeholder before assigning a real attribute id.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Drawing Attribute tag embedded in ISF stream does not match…
- ExtendedProperty is already part of the…
- Global Custom Attribute tag embedded in ISF stream does not…
- InvalidMatrixContainsInfinity
- InvalidMatrixContainsNaN
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/5602567b955cc601.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/ExtendedProperty.cs:23
namespace System.Windows.Ink
{
/// <summary>
/// Drawing Attribute Key/Value pair for specifying each attribute
/// </summary>
internal sealed class ExtendedProperty
{
/// <summary>
/// Create a new drawing attribute with the specified key and value
/// </summary>
/// <param name="id">Identifier of attribute</param>
/// <param name="value">Attribute value - not that the Type for value is tied to the id</param>
/// <exception cref="System.ArgumentException">Value type must be compatible with attribute Id</exception>
internal ExtendedProperty(Guid id, object value)
{
if (id == Guid.Empty)
{
throw new ArgumentException(SR.InvalidGuid);
}
_id = id;
Value = value;
}
/// <summary>Returns a value that can be used to store and lookup
/// ExtendedProperty objects in a hash table</summary>
public override int GetHashCode()
{
return Id.GetHashCode() ^ Value.GetHashCode();
}
/// <summary>Determine if two ExtendedProperty objects are equal</summary>
public override bool Equals(object obj)
{
if (obj == null || obj.GetType() != GetType())
{
return false;View on GitHub (pinned to 81131a70a4)