{"record":{"id":"00c170341cdc5013","repo":"dotnet/wpf","slug":"sr-parsercompatduplicate-formatted-with-oldxmlns-newxmlns","errorCode":null,"errorMessage":"SR.ParserCompatDuplicate formatted with (oldXmlns, newXmlns) - duplicate XmlnsCompatibleWithAttribute mapping for the same old namespace","messagePattern":"SR\\.ParserCompatDuplicate formatted with \\(oldXmlns, newXmlns\\) - duplicate XmlnsCompatibleWithAttribute mapping for the same old namespace","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XmlnsCache.cs","lineNumber":393,"sourceCode":"                                                typeof(XmlnsCompatibleWithAttribute));\n#endif\n\n                for(int attrIdx=0; attrIdx<attributes.Length; attrIdx++)\n                {\n                    string oldXmlns = null;\n                    string newXmlns = null;\n\n                    GetNamespacesFromCompatAttr(attributes[attrIdx], out oldXmlns, out newXmlns);\n\n                    if (String.IsNullOrEmpty(oldXmlns) || String.IsNullOrEmpty(newXmlns))\n                    {\n                        throw new ArgumentException(SR.Format(SR.ParserAttributeArgsLow, \"XmlnsCompatibleWithAttribute\"));\n                    }\n\n                    if (_compatTable.ContainsKey(oldXmlns) &&\n                        _compatTable[oldXmlns] != newXmlns)\n                    {\n                        throw new InvalidOperationException(SR.Format(SR.ParserCompatDuplicate, oldXmlns,\n                                                                   _compatTable[oldXmlns]));\n                    }\n                    _compatTable[oldXmlns] = newXmlns;\n                    _compatTableReverse[newXmlns] = oldXmlns;\n                }\n            }\n        }\n\n        // Table where Xml namespace is the key, and value is a list of assembly / clrns pairs\n        private HybridDictionary _cacheTable = null;\n\n        // Table where old namespaces are the key, and new namespaces are the value\n        private Dictionary<string, string> _compatTable = null;\n\n        // Table where new namespaces are the key, and old namespaces are the value\n        private Dictionary<string, string> _compatTableReverse = null;\n\n#if !PBTCOMPILER","sourceCodeStart":375,"sourceCodeEnd":411,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XmlnsCache.cs#L375-L411","documentation":"XmlnsCache throws InvalidOperationException when two XmlnsCompatibleWithAttribute declarations map the same OldNamespace to different NewNamespace values. The compatibility table (_compatTable) can hold only one new-namespace mapping per old namespace, so a conflicting second mapping is ambiguous and rejected.","triggerScenarios":"Calling AddReferencedAssemblies or GetMappingArray while scanning assemblies containing e.g. [assembly: XmlnsCompatibleWith(\"old-ns\", \"ns-A\")] in one assembly and [assembly: XmlnsCompatibleWith(\"old-ns\", \"ns-B\")] in another (or the same) assembly.","commonSituations":"Referencing two versions of a control library that each declare a different compatibility target for the same old namespace; a library rename where an old compatibility shim was left alongside the new mapping.","solutions":["Find all XmlnsCompatibleWithAttribute declarations whose OldNamespace matches the oldXmlns in the message and remove or correct the conflicting one","Ensure only one NewNamespace is declared per OldNamespace across all referenced assemblies","Remove stale compatibility shims from older library versions still referenced by the project","If both mappings are needed for different scenarios, split the assemblies so both are never loaded together in the same XAML compilation"],"exampleFix":"// before\n[assembly: XmlnsCompatibleWith(\"clr-namespace:Lib.V1\", \"clr-namespace:Lib.V2\")]\n[assembly: XmlnsCompatibleWith(\"clr-namespace:Lib.V1\", \"clr-namespace:Lib.V3\")] // conflict\n\n// after\n[assembly: XmlnsCompatibleWith(\"clr-namespace:Lib.V1\", \"clr-namespace:Lib.V3\")]","handlingStrategy":"validation","validationCode":"var seen = new Dictionary<string,string>();\nforeach (var a in assemblies.SelectMany(a => a.GetCustomAttributes<XmlnsCompatibleWithAttribute>()))\n{\n    if (seen.TryGetValue(a.OldNamespace, out var prev) && prev != a.NewNamespace)\n        throw new InvalidOperationException($\"Conflicting XmlnsCompatibleWith mapping for {a.OldNamespace}\");\n    seen[a.OldNamespace] = a.NewNamespace;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare exactly one XmlnsCompatibleWithAttribute per old namespace across all referenced assemblies","Remove compatibility shims from old library versions when upgrading","Document namespace migrations to avoid parallel conflicting mappings"],"tags":["wpf","xaml","markup-compiler","conflict"],"backgroundTag":"conflicting-config-options","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"}