dotnet/wpf · error · ArgumentNullException
ArgumentNullException(nameof(value))
Error message
ArgumentNullException(nameof(value))
What it means
The StaticExtension.Member property setter rejects null with ArgumentNullException because the Member string is the core payload of the extension (marked [ConstructorArgument("member")]). The member path must always be a non-null string, even if it may later prove malformed.
Solutions
- Pass a non-null 'Type.Member' string to the constructor or Member setter.
- Coalesce nulls at the call site: new StaticExtension(member ?? fallback).
- Check earlier parsing/config code that produced the null member string.
Example fix
// before var ext = new StaticExtension(GetMemberName()); // may return null // after var ext = new StaticExtension(GetMemberName() ?? "MyNamespace.MyClass.MyConstant");
Defensive patterns
Strategy: validation
Validate before calling
if (member is null) throw new InvalidOperationException("StaticExtension.Member cannot be null"); Type guard
static bool IsValidMember(string? m) => m is not null;
Try / catch
try { ext.Member = candidate; } catch (ArgumentNullException) { /* supply default or abort */ } Prevention
- Null-check config/attribute strings before constructing StaticExtension.
- Use ?? fallback at the call site.
- Treat Member as a required [ConstructorArgument] in serialization code.
When it happens
Trigger: Assigning ext.Member = null, or calling new StaticExtension(null) — the constructor delegates to the Member setter.
Common situations: Deserializing markup extension settings where the member value is missing; conditional code passing a variable that is null; data-bound config strings that failed to load.
Related errors
- ArgumentNullException(nameof(type))
- ArgumentNullException(nameof(typeName))
- XmlReader is null
- ArgumentNullException(nameof(schemaContext))
- ArgumentNullException(nameof(typeName))
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/5465993b1b4a01d5.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Windows/Markup/StaticExtension.cs:160
currentType = currentType.BaseType;
}
while (currentType is not null);
value = null;
return false;
}
/// <summary>
/// The static field or property represented by a string. This string is
/// of the format Prefix:ClassName.FieldOrPropertyName. The Prefix is
/// optional, and refers to the XML prefix in a Xaml file.
/// </summary>
[ConstructorArgument("member")]
public string Member
{
get => _member;
set => _member = value ?? throw new ArgumentNullException(nameof(value));
}
[DefaultValue(null)]
public Type MemberType
{
get => _memberType;
set => _memberType = value ?? throw new ArgumentNullException(nameof(value));
}
}
}
View on GitHub (pinned to 81131a70a4)