dotnet/wpf · error · ArgumentException
SR.ParserAttributeArgsLow with 'XmlnsDefinitionAttribute'…
Error message
SR.ParserAttributeArgsLow with 'XmlnsDefinitionAttribute' (missing XmlnsDefinitionAttribute constructor arguments)
What it means
When XmlnsCache.LoadClrnsToAssemblyNameMappingCache (invoked from AddReferencedAssemblies) parses [XmlnsDefinitionAttribute] instances, both xmlNamespace and clrNamespace must be non-empty. GetNamespacesFromDefinitionAttr returned null/empty for one of them, so an ArgumentException with ParserAttributeArgsLow is thrown — the attribute is missing required constructor arguments.
Solutions
- Fix the [XmlnsDefinition] declaration to supply both xmlns and clrNamespace arguments
- Check all referenced assemblies for malformed XmlnsDefinitionAttribute usages and correct or remove them
- Rebuild the referenced assembly to rule out stale/incorrect metadata
Example fix
// before
[assembly: XmlnsDefinition("http://mycompany.com/schema")] // missing clrNamespace
// after
[assembly: XmlnsDefinition("http://mycompany.com/schema", "MyCompany.Controls")] Defensive patterns
Strategy: validation
Validate before calling
foreach (var attr in asm.GetCustomAttributesData())
{
if (attr.AttributeType.Name == "XmlnsDefinitionAttribute" && attr.ConstructorArguments.Count < 2)
throw new InvalidOperationException($"{asm}: XmlnsDefinitionAttribute missing required arguments");
} Try / catch
try { AddReferencedAssemblies(references); }
catch (ArgumentException ex) when (ex.Message.Contains("ParserAttributeArgsLow"))
{ log.Error("A referenced assembly declares an XmlnsDefinitionAttribute without xmlns/clrNamespace", ex); } Prevention
- Always provide both xmlns and clrNamespace in [assembly: XmlnsDefinition]
- Scan third-party assemblies for malformed attributes before referencing them
- Add assembly-level attribute validation to build/CI scripts
When it happens
Trigger: A referenced assembly contains [assembly: XmlnsDefinition("http://ns")] with no clrNamespace, or [XmlnsDefinition(null, "Ns")], and the assembly is being scanned when references are added.
Common situations: Hand-written assembly-level attributes where the second argument was omitted; code generators emitting malformed XmlnsDefinition; conditional compilation stripping an argument; assembly references pointing at a broken/partially built library.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- ArgumentNullException(nameof(clrNamespace))
- ArgumentNullException(nameof(contentType))
- ArgumentNullException(nameof(loaderType))
- ArgumentNullException(nameof(newNamespace))
- ArgumentNullException(nameof(oldNamespace))
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/cb79ed45ace38bba.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XmlnsCache.cs:313
private void LoadClrnsToAssemblyNameMappingCache(Assembly[] asmList)
{
List<ClrNamespaceAssemblyPair> pairList;
// For each assembly, enmerate all the XmlnsDefinition attributes.
for(int asmIdx=0; asmIdx<asmList.Length; asmIdx++)
{
string assemblyName = asmList[asmIdx].FullName;
CustomAttributeData[] attributes = GetAttributes(asmList[asmIdx],
"System.Windows.Markup.XmlnsDefinitionAttribute");
for(int attrIdx=0; attrIdx<attributes.Length; attrIdx++)
{
string xmlns = null;
string clrns = null;
GetNamespacesFromDefinitionAttr(attributes[attrIdx], out xmlns, out clrns);
if (string.IsNullOrEmpty(xmlns) || string.IsNullOrEmpty(clrns) )
{
throw new ArgumentException(SR.Format(SR.ParserAttributeArgsLow, "XmlnsDefinitionAttribute"));
}
if (!_cacheTable.Contains(xmlns))
{
_cacheTable[xmlns] = new List<ClrNamespaceAssemblyPair>();
}
pairList = (List<ClrNamespaceAssemblyPair>)_cacheTable[xmlns];
pairList.Add(new ClrNamespaceAssemblyPair(clrns, assemblyName));
}
}
}
#else
// Get a list of (clrNs, asmName) pairs for a given XmlNs from a
// given list of Assemblies. This returns a list that the caller
// Will add to the _cacheTable. At runtime the needed assemblies
// appear with various XmlNs namespaces one at a time as we read the BAML
private List<ClrNamespaceAssemblyPair> GetClrnsToAssemblyNameMappingList(View on GitHub (pinned to 81131a70a4)