dotnet/wpf · error · ArgumentException
PROPSPEC union selector is unrecognized.
Error message
PROPSPEC union selector is unrecognized.
What it means
ManagedFilter's ManagedPropSpec validates the PropSpecType union selector: only Id and Name are supported. Setting any other PROPSPEC selector (e.g., pointer-based lpwstr variants or other union members) throws ArgumentException because the managed wrapper cannot represent it.
Solutions
- Use only PropSpecType.Id (property ID) or PropSpecType.Name (string name) selectors.
- Convert unsupported selectors before passing: resolve numeric IDs or names on the caller side.
- Catch ArgumentException from the PropType setter and map/normalize the spec type first.
Example fix
// before spec.PropType = PropSpecType.Pointer; // throws // after spec.PropType = PropSpecType.Id; spec.PropId = 2; // or use PropSpecType.Name with a string name
Defensive patterns
Strategy: validation
Validate before calling
if (propSpec.Type != PropSpecType.Id && propSpec.Type != PropSpecType.Name) throw new ArgumentException("Only Id or Name PROPSPEC selectors are supported", nameof(propSpec)); Type guard
static bool IsSupportedPropSpec(PropSpec s) => s.Type == PropSpecType.Id || s.Type == PropSpecType.Name;
Try / catch
try { wrapper.PropType = spec.Type; } catch (ArgumentException) { /* normalize to Id/Name or skip */ } Prevention
- Whitelist PropSpecType.Id and PropSpecType.Name in property-spec construction
- Reject or convert exotic native PROPSPEC selectors at the interop boundary
When it happens
Trigger: Constructing a ManagedPropSpec or setting its PropType to a PropSpecType value other than PropSpecType.Id or PropSpecType.Name.
Common situations: Marshaling native PROPSPEC structs from IFilter/property-system code that uses numeric/pointer selectors; copy-pasting property-spec code using FullPropSpec types not covered by the wrapper.
Related errors
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/7662d422bbd5334d.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/ManagedFilter.cs:47
/// <value></value>
internal PropSpecType PropType
{
get
{
return _propType;
}
// The following code is not being compiled, but should not be removed; since some container-filter
// plug-in (e.g. metadata) may use it in future.
#if false
set
{
switch (value)
{
case PropSpecType.Id: break;
case PropSpecType.Name: break;
default:
throw new ArgumentException(SR.FilterPropSpecUnknownUnionSelector, "propSpec");
}
_propType = value;
}
#endif
}
/// <summary>
/// Property name (only valid if PropType is Name
/// </summary>
/// <value></value>
internal string PropName
{
get
{
System.Diagnostics.Debug.Assert(_propType == PropSpecType.Name, "ManagedPropSpec.PropName - PropName only meaningful if PropType is type string");
return _name;
}
setView on GitHub (pinned to 81131a70a4)