{"record":{"id":"409cd0a1e29aea85","repo":"dotnet/wpf","slug":"invalid-xaml-type-name-list-string-error-message-produced-by","errorCode":null,"errorMessage":"Invalid XAML type-name list string; error message produced by XamlTypeName.ParseListInternal (e.g. \"The string '{0}' is not a valid XAML type name list. Type name lists are comma-delimited lists of types; such as 'x:String, x:Int32'.\")","messagePattern":"Invalid XAML type-name list string; error message produced by XamlTypeName\\.ParseListInternal \\(e\\.g\\. \"The string '(.+?)' is not a valid XAML type name list\\. Type name lists are comma-delimited lists of types; such as 'x:String, x:Int32'\\.\"\\)","errorType":"exception","errorClass":"XamlParseException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/XamlScanner.cs","lineNumber":382,"sourceCode":"            if (IsXDataElement(xmlns, name))\n            {\n                // If XData don't Enqueue the <x:XData> node.\n                // just queue the InnerXml as TEXT (w/ IsTextXML == true).\n                // This will advance the \"current\" xml node to the </x:XData>\n                // which will be skipped when we return and the main loop\n                // Read()s to the \"next\" XmlNode.\n                ReadInnerXDataSection();\n                return true;\n            }\n\n            IList<XamlTypeName> typeArgs = null;\n            if (_typeArgumentAttribute is not null)\n            {\n                string error;\n                typeArgs = XamlTypeName.ParseListInternal(_typeArgumentAttribute.Value, _parserContext.FindNamespaceByPrefix, out error);\n                if (typeArgs is null)\n                {\n                    throw new XamlParseException(_typeArgumentAttribute.LineNumber, _typeArgumentAttribute.LinePosition, error);\n                }\n            }\n\n            XamlTypeName typeName = new XamlTypeName(xmlns, name, typeArgs);\n            node.Type = _parserContext.GetXamlType(typeName, true);\n\n            // Finish initializing the attributes in the context of the\n            // current Element.\n            PostprocessAttributes(node);\n\n            if (_scannerStack.Depth > 0)\n            {\n                // Sub-elements (and Text) are the definition of Content\n                _scannerStack.CurrentlyInContent = true;\n            }\n\n            if (!node.IsEmptyTag)\n            {","sourceCodeStart":364,"sourceCodeEnd":400,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/XamlScanner.cs#L364-L400","documentation":"When the scanner encounters an x:TypeArguments attribute, ReadObjectElement_Object calls XamlTypeName.ParseListInternal to parse the comma-delimited generic type argument list. If parsing fails, ParseListInternal returns null and produces an error message (e.g. \"The string '{0}' is not a valid XAML type name list...\"), which is thrown as XamlParseException with line/position info. The library throws this because a generic instantiation cannot be constructed without valid type arguments.","triggerScenarios":"XAML markup contains x:TypeArguments=\"...\" whose value is not a syntactically valid comma-delimited list of namespace-prefixed type names (missing prefix, bad separators, nested generics written incorrectly, empty entries).","commonSituations":"Using generic types like Dictionary<TKey,TValue> in XAML with typos in the list; missing xmlns prefix declarations for the argument types; copying type syntax from C# (Dictionary<string, int>) instead of XAML syntax.","solutions":["Write the list in valid XAML form with prefixed names, e.g. x:TypeArguments=\"sys:String, sys:Int32\"","Ensure every referenced prefix (x:, sys:, local:) is declared with xmlns on the element or root","Check comma placement — no trailing commas, no empty items in the list"],"exampleFix":"// before\n<local:MyGeneric x:TypeArguments=\"string, int\" />\n// after (prefixes declared and used)\n<local:MyGeneric xmlns:sys=\"clr-namespace:System;assembly=mscorlib\"\n                 x:TypeArguments=\"sys:String, sys:Int32\" />","handlingStrategy":"validation","validationCode":"static bool IsValidTypeArgumentList(string s) => !string.IsNullOrWhiteSpace(s) && s.Split(',').All(t => t.Trim().Contains(':') && !t.Trim().EndsWith(\",\"));","typeGuard":null,"tryCatchPattern":"try { LoadXaml(xaml); } catch (System.Xaml.XamlParseException ex) when (ex.Message.Contains(\"valid XAML type name list\")) { FixTypeArguments(ex.LineNumber); throw; }","preventionTips":["Always use xmlns-prefixed type names in x:TypeArguments","Declare all prefixes (sys:, x:, local:) on the root element","Mirror C# generics as x:TypeArguments=\"pfx:Outer(pfx:Inner)\" for nested generics","Keep commas separating exactly one name per argument"],"tags":["xaml","typename","generics","parsing"],"backgroundTag":"invalid-argument-format","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}