{"record":{"id":"c0f2e7aa567d6e61","repo":"dotnet/wpf","slug":"sr-duplicatedcompatibleuri","errorCode":null,"errorMessage":"SR.DuplicatedCompatibleUri","messagePattern":"SR\\.DuplicatedCompatibleUri","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Annotations/Storage/XmlStreamStore.cs","lineNumber":805,"sourceCode":"                }\n                allNamespaces.Add(knownNamespace);\n            }\n\n            // check compatible namespaces\n            foreach (KeyValuePair<Uri, IList<Uri>> item in knownNamespaces)\n            {\n                if (item.Value != null)\n                {\n                    foreach (Uri name in item.Value)\n                    {\n                        if (name == null)\n                        {\n                            throw new ArgumentException(SR.NullUri, nameof(knownNamespaces));\n                        }\n\n                        if (allNamespaces.Contains(name))\n                        {\n                            throw new ArgumentException(SR.DuplicatedCompatibleUri, nameof(knownNamespaces));\n                        }\n                        allNamespaces.Add(name);\n                    }//foreach\n                }//if\n            }//foreach\n        }\n\n        /// <summary>\n        /// Creates and initializes the XmlCompatibilityReader\n        /// </summary>\n        /// <param name=\"knownNamespaces\">Dictionary of external known namespaces</param>\n        /// <returns>The XmlCompatibilityReader</returns>\n        private XmlCompatibilityReader SetupReader(IDictionary<Uri, IList<Uri>> knownNamespaces)\n        {\n            IList<string> supportedNamespaces = new List<string>();\n\n            //add AnnotationFramework namespaces\n            foreach (Uri name in _predefinedNamespaces.Keys)","sourceCodeStart":787,"sourceCodeEnd":823,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Annotations/Storage/XmlStreamStore.cs#L787-L823","documentation":"CheckKnownNamespaces throws ArgumentException (SR.DuplicatedCompatibleUri) when a compatible namespace Uri appears more than once - either repeated within one compatible list or already registered as another known/compatible namespace. All namespaces collected must be distinct.","triggerScenarios":"new XmlStreamStore(stream, knownNamespaces) where the same Uri is listed as compatible with multiple known namespaces, or duplicated inside a single item.Value list.","commonSituations":"Merging compatibility tables where several namespaces declare the same compatibility target; copy-pasted lists; config files whose compatibility sections overlap.","solutions":["Deduplicate each compatible list (Distinct()) and against already-collected namespaces before constructing the store.","Keep a running HashSet<Uri> of all namespaces while building the map and skip any Uri already present.","Restructure configuration so each compatible namespace is declared exactly once."],"exampleFix":"// before\nknown[a] = new List<Uri> { sharedUri };\nknown[b] = new List<Uri> { sharedUri }; // duplicate compatible Uri\n\n// after\nknown[a] = new List<Uri> { sharedUri };\nknown[b] = new List<Uri>();","handlingStrategy":"validation","validationCode":"var all = new HashSet<Uri>();\nforeach (var kv in knownNamespaces) {\n    all.Add(kv.Key);\n    foreach (var u in kv.Value ?? (IList<Uri>)Array.Empty<Uri>())\n        if (!all.Add(u)) throw new ArgumentException($\"Duplicate compatible namespace: {u}\");\n}","typeGuard":null,"tryCatchPattern":"try { var store = new XmlStreamStore(stream, knownNamespaces); }\ncatch (ArgumentException ex) when (ex.ParamName == \"knownNamespaces\") { /* deduplicate compatible lists and retry */ }","preventionTips":["Maintain a global HashSet<Uri> while building compatibility tables.","Run Distinct() on every compatible-namespace list before constructing the store.","Design config so each compatible namespace is declared in exactly one place."],"tags":["namespace","duplicate","wpf","argument-exception"],"backgroundTag":"invalid-argument-value","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"}