dotnet/wpf · error · ArgumentException
SR.UnsupportedProperty
Error message
SR.UnsupportedProperty
What it means
The PropertyCondition constructor validates the given AutomationProperty against Schema.GetPropertyInfo; unknown properties throw ArgumentException(SR.UnsupportedProperty). PropertyCondition can only be built from properties the UI Automation client schema knows about, because it must map to an unmanaged UIA condition.
Solutions
- Build conditions only with known identifiers like AutomationElement.NameProperty or pattern identifier properties
- Validate the property id against AutomationProperty references in the schema before constructing the condition
- For custom provider properties, search client-side by enumerating elements instead of using PropertyCondition
Example fix
// before var cond = new PropertyCondition(myCustomProperty, "value"); // ArgumentException // after var cond = new PropertyCondition(AutomationElement.AutomationIdProperty, "value");
Defensive patterns
Strategy: validation
Validate before calling
var known = new[]{ AutomationElement.NameProperty, AutomationElement.AutomationIdProperty, AutomationElement.ControlTypeProperty };
if (!known.Contains(property)) return null; // don't build the condition Try / catch
try { var c = new PropertyCondition(p, v); } catch (ArgumentException) { /* fall back to client-side filter */ } Prevention
- Build PropertyCondition only from schema-known identifiers
- Validate dynamic property sources before constructing
- Use client-side filtering for custom provider properties
When it happens
Trigger: new PropertyCondition(customOrUnknownProperty, value); passing a property identifier obtained from LookupById for an id not in the client schema; passing an AutomationProperty from a different UIA surface.
Common situations: Constructing search conditions dynamically from config where property names don't map to schema properties; using provider-side or custom-registered properties in client-side conditions; typos in property identifier selection.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- SR.Format(SR.PropertyConditionIncorrectType…
- SR.UnsupportedProperty
- E_INVALIDARG
- name
- SR.BeginEndTextContainerMismatch
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/7711a9ac3096492d.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/System/Windows/Automation/PropertyCondition.cs:127
#endregion Public Properties
//------------------------------------------------------
//
// Private Methods
//
//------------------------------------------------------
#region Private Methods
private void Init(AutomationProperty property, object val, PropertyConditionFlags flags )
{
ArgumentNullException.ThrowIfNull(property);
AutomationPropertyInfo info;
if (!Schema.GetPropertyInfo(property, out info))
{
throw new ArgumentException(SR.UnsupportedProperty);
}
// Check type is appropriate: NotSupported is allowed against any property,
// null is allowed for any reference type (ie not for value types), otherwise
// type must be assignable from expected type.
Type expectedType = info.Type;
if (val != AutomationElement.NotSupported &&
((val == null && expectedType.IsValueType)
|| (val != null && !expectedType.IsAssignableFrom(val.GetType()))))
{
throw new ArgumentException(SR.Format(SR.PropertyConditionIncorrectType, property.ProgrammaticName, expectedType.Name));
}
if ((flags & PropertyConditionFlags.IgnoreCase) != 0)
{
Misc.ValidateArgument(val is string, nameof(SR.IgnoreCaseRequiresString));
}
View on GitHub (pinned to 81131a70a4)