{"record":{"id":"308add91f562829e","repo":"dotnet/wpf","slug":"type-parse-error-string-from-xamltypename-parseinternal-e-g","errorCode":null,"errorMessage":"type-parse error string from XamlTypeName.ParseInternal (e.g. SR.PrefixNotFound/InvalidTypeString)","messagePattern":"type-parse error string from XamlTypeName\\.ParseInternal \\(e\\.g\\. SR\\.PrefixNotFound/InvalidTypeString\\)","errorType":"exception","errorClass":"XamlParseException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/MeScanner.cs","lineNumber":293,"sourceCode":"                        builder.Append(value[idx + 1]);\n                    }\n\n                    // pick up again after that\n                    start = idx + 2;\n                }\n            }\n            while (start < value.Length);\n            string result = builder.ToString();\n            return result;\n        }\n\n        private void ResolveTypeName(string longName)\n        {\n            string error;\n            XamlTypeName typeName = XamlTypeName.ParseInternal(longName, _context.FindNamespaceByPrefix, out error);\n            if (typeName is null)\n            {\n                throw new XamlParseException(this, error);\n            }\n\n            // In curly form, we search for TypeName + 'Extension' before TypeName\n            string bareTypeName = typeName.Name;\n            typeName.Name += KnownStrings.Extension;\n            XamlType xamlType = _context.GetXamlType(typeName, false);\n            // This would be cleaner if we moved the Extension fallback logic out of XSC\n            if (xamlType is null ||\n                // Guard against Extension getting added twice\n                (xamlType.UnderlyingType is not null &&\n                 KS.Eq(xamlType.UnderlyingType.Name, typeName.Name + KnownStrings.Extension)))\n            {\n                typeName.Name = bareTypeName;\n                xamlType = _context.GetXamlType(typeName, true);\n            }\n\n            _tokenXamlType = xamlType;\n            _tokenNamespace = typeName.Namespace;","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/MeScanner.cs#L275-L311","documentation":"MeScanner.ResolveTypeName resolves the bare type name inside curly markup-extension form (e.g. '{StaticResource ...}' where 'StaticResource' must resolve to 'StaticResourceExtension'). It calls XamlTypeName.ParseInternal; if that returns null (PrefixNotFound, InvalidTypeString, etc.), the stored error string is thrown as XamlParseException.","triggerScenarios":"Using a markup extension whose name cannot be resolved: unknown/misspelled extension name, missing xmlns prefix mapping, or a syntactically invalid type-name portion of the curly string.","commonSituations":"Custom markup extensions not registered via XmlnsDefinition, typos in extension names, missing namespace declarations when consuming third-party XAML libraries.","solutions":["Verify the extension name is correct and the extension type exists","Register the extension's assembly/namespace via xmlns declarations or XmlnsDefinition attributes","Fix the type-string syntax inside the curly form","Catch XamlParseException around scanner/parser use and inspect the inner error text"],"exampleFix":"// before\n<TextBlock Text=\"{CustomxExtension Foo}\"/> // unregistered name\n// after\nxmlns:ext=\"clr-namespace:MyApp.Extensions;assembly=MyApp\"\n<TextBlock Text=\"{ext:CustomExtension Foo}\"/>","handlingStrategy":"try-catch","validationCode":"// verify the extension type resolves before curly-form scanning\nbool ExtensionResolves(string name, XamlSchemaContext ctx)\n{\n    var tn = XamlTypeName.Parse(name, ctx.FindNamespaceByPrefix, out _);\n    return tn != null && ctx.GetXamlType(tn, false) != null;\n}","typeGuard":null,"tryCatchPattern":"try { scanner/readResult = ...; }\ncatch (XamlParseException ex) { /* ex.Message carries the underlying PrefixNotFound/InvalidTypeString text from ParseInternal */ }","preventionTips":["Register custom extension types with XmlnsDefinition","Follow the 'NameExtension' naming convention for curly-form lookup","Test third-party namespaces resolve before deployment"],"tags":["xaml","markup-extension","type-resolution"],"backgroundTag":"resource-not-found","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"}