{"record":{"id":"cb79ed45ace38bba","repo":"dotnet/wpf","slug":"sr-parserattributeargslow-with-xmlnsdefinitionattribute","errorCode":null,"errorMessage":"SR.ParserAttributeArgsLow with 'XmlnsDefinitionAttribute' (missing XmlnsDefinitionAttribute constructor arguments)","messagePattern":"SR\\.ParserAttributeArgsLow with 'XmlnsDefinitionAttribute' \\(missing XmlnsDefinitionAttribute constructor arguments\\)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XmlnsCache.cs","lineNumber":313,"sourceCode":"        private void LoadClrnsToAssemblyNameMappingCache(Assembly[] asmList)\n        {\n            List<ClrNamespaceAssemblyPair> pairList;\n            // For each assembly, enmerate all the XmlnsDefinition attributes.\n            for(int asmIdx=0; asmIdx<asmList.Length; asmIdx++)\n            {\n                string assemblyName = asmList[asmIdx].FullName;\n                CustomAttributeData[] attributes = GetAttributes(asmList[asmIdx],\n                                                \"System.Windows.Markup.XmlnsDefinitionAttribute\");\n                for(int attrIdx=0; attrIdx<attributes.Length; attrIdx++)\n                {\n                    string xmlns = null;\n                    string clrns = null;\n\n                    GetNamespacesFromDefinitionAttr(attributes[attrIdx], out xmlns, out clrns);\n\n                    if (string.IsNullOrEmpty(xmlns) || string.IsNullOrEmpty(clrns) )\n                    {\n                        throw new ArgumentException(SR.Format(SR.ParserAttributeArgsLow, \"XmlnsDefinitionAttribute\"));\n                    }\n\n                    if (!_cacheTable.Contains(xmlns))\n                    {\n                        _cacheTable[xmlns] = new List<ClrNamespaceAssemblyPair>();\n                    }\n                    pairList = (List<ClrNamespaceAssemblyPair>)_cacheTable[xmlns];\n                    pairList.Add(new ClrNamespaceAssemblyPair(clrns, assemblyName));\n                }\n            }\n        }\n\n#else\n        // Get a list of (clrNs, asmName) pairs for a given XmlNs from a\n        // given list of Assemblies.  This returns a list that the caller\n        // Will add to the _cacheTable.   At runtime the needed assemblies\n        // appear with various XmlNs namespaces one at a time as we read the BAML\n        private List<ClrNamespaceAssemblyPair> GetClrnsToAssemblyNameMappingList(","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XmlnsCache.cs#L295-L331","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n[assembly: XmlnsDefinition(\"http://mycompany.com/schema\")] // missing clrNamespace\n// after\n[assembly: XmlnsDefinition(\"http://mycompany.com/schema\", \"MyCompany.Controls\")]","handlingStrategy":"validation","validationCode":"foreach (var attr in asm.GetCustomAttributesData())\n{\n    if (attr.AttributeType.Name == \"XmlnsDefinitionAttribute\" && attr.ConstructorArguments.Count < 2)\n        throw new InvalidOperationException($\"{asm}: XmlnsDefinitionAttribute missing required arguments\");\n}","typeGuard":null,"tryCatchPattern":"try { AddReferencedAssemblies(references); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"ParserAttributeArgsLow\"))\n{ log.Error(\"A referenced assembly declares an XmlnsDefinitionAttribute without xmlns/clrNamespace\", ex); }","preventionTips":["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"],"tags":["wpf","xaml","attribute","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}