dotnet/wpf · error · ArgumentException
Property not set.
Error message
Property not set.
What it means
The ExtendedPropertyCollection indexer getter resolves the property by attributeId via GetExtendedPropertyById; when no property with that GUID exists it throws ArgumentException(SR.EPNotFound, nameof(attributeId)) — 'Property not set.' — because reading an unset extended property has no default value.
Solutions
- Check Contains(attributeId) / HasPropertyData before reading via the indexer.
- Use TryGetValue-style access by wrapping the read in try/catch for ArgumentException.
- Ensure the pipeline stage that writes the property always runs before the read.
- Provide an explicit default value at the call site when the property is optional.
Example fix
// before var value = properties[attributeId]; // ArgumentException: Property not set. // after object value = properties.Contains(attributeId) ? properties[attributeId] : defaultValue;
Defensive patterns
Strategy: validation
Validate before calling
object value = properties.Contains(attributeId)
? properties[attributeId]
: defaultValue; Type guard
static bool TryGetProperty(ExtendedPropertyCollection c, Guid id, out object value)
{
if (c.Contains(id)) { value = c[id]; return true; }
value = null; return false;
} Try / catch
object value;
try { value = properties[attributeId]; }
catch (ArgumentException) { value = defaultValue; /* property not set */ } Prevention
- Check Contains before indexer reads
- Provide explicit defaults for optional properties
- Guarantee writer stages run before readers
When it happens
Trigger: Reading collection[guid] (or GetPropertyData on a Stroke/ContextNode) where the property was never added, or before it was set; checking a property added only conditionally by another code path.
Common situations: Reading optional metadata from ink imported from another application; assuming a property was set by a previous pipeline stage that skipped it; using a GUID from a different ink schema/version.
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
- The GUID is not part of the ExtendedPropertyCollection.
- 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/5b0d3fe5ce3dd0aa.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/ExtendedPropertyCollection.cs:228
}
/// <summary>
/// Generic accessor for the ExtendedPropertyCollection.
/// </summary>
/// <param name="attributeId">Attribue Id to find</param>
/// <returns>Value for attribute specified by Id</returns>
/// <exception cref="System.ArgumentException">Specified identifier was not found</exception>
/// <remarks>
/// Note that you can access extended properties via this indexer.
/// </remarks>
internal object this[Guid attributeId]
{
get
{
ExtendedProperty ep = GetExtendedPropertyById(attributeId);
if (ep == null)
{
throw new ArgumentException(SR.EPNotFound, nameof(attributeId));
}
return ep.Value;
}
set
{
ArgumentNullException.ThrowIfNull(value);
for (int i = 0; i < _extendedProperties.Count; i++)
{
ExtendedProperty currentProperty = _extendedProperties[i];
if (currentProperty.Id == attributeId)
{
object oldValue = currentProperty.Value;
//this will raise events
currentProperty.Value = value;
//raise change if anyone is listening
if (this.Changed != null)View on GitHub (pinned to 81131a70a4)