{"record":{"id":"112e126395608345","repo":"dotnet/wpf","slug":"sr-format-sr-typenotfound-xamltype-getqualifiedname","errorCode":null,"errorMessage":"SR.Format(SR.TypeNotFound, xamlType.GetQualifiedName())","messagePattern":"SR\\.Format\\(SR\\.TypeNotFound, xamlType\\.GetQualifiedName\\(\\)\\)","errorType":"exception","errorClass":"XamlParseException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Context/ObjectWriterContext.cs","lineNumber":161,"sourceCode":"        }\n\n        #region ServiceProvider Interfaces\n\n        // This class doesn't implement the IServiceProvider.  That is done\n        // with worker classes ValueConverterContext or MarkupConverterContext.\n        // The worker class implements IServiceProvider but uses the real\n        // context for the implementation of the actual services.\n\n        internal Type ServiceProvider_Resolve(string qName)\n        {\n            // As soon as we have the necessary setting on ObjectWriter, we need to start passing\n            // the local assembly into the context; currently, this will only return publics.\n            XamlType xamlType = ServiceProvider_ResolveXamlType(qName);\n            if (xamlType is null || xamlType.UnderlyingType is null)\n            {\n                XamlTypeName name = XamlTypeName.Parse(qName, _serviceProviderContext);\n                xamlType = GetXamlType(name, true, true);\n                throw new XamlParseException(SR.Format(SR.TypeNotFound, xamlType.GetQualifiedName()));\n            }\n\n            return xamlType.UnderlyingType;\n        }\n\n        internal XamlType ServiceProvider_ResolveXamlType(string qName)\n        {\n            return ResolveXamlType(qName, true);\n        }\n\n        internal AmbientPropertyValue ServiceProvider_GetFirstAmbientValue(IEnumerable<XamlType> ceilingTypes, XamlMember[] properties)\n        {\n            List<AmbientPropertyValue> valueList = FindAmbientValues(ceilingTypes, searchLiveStackOnly: false, types: null, properties, true);\n            return (valueList.Count == 0) ? null : valueList[0];\n        }\n\n        internal object ServiceProvider_GetFirstAmbientValue(XamlType[] types)\n        {","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Context/ObjectWriterContext.cs#L143-L179","documentation":"ObjectWriterContext.ServiceProvider_Resolve resolves a qualified XAML type name to a CLR Type. When neither the direct namespace lookup (ServiceProvider_ResolveXamlType) nor the fallback XamlTypeName.Parse/GetXamlType path yields a type with an underlying CLR type, it throws XamlParseException with SR.TypeNotFound naming the qualified name.","triggerScenarios":"XAML markup (or IXamlSchemaContextProvider-based resolution) references a type whose xmlns-prefix mapping does not resolve to a loaded assembly containing that type — e.g. during x:Type resolution or type-converted property values.","commonSituations":"Missing assembly reference in the project; wrong clr-namespace/assembly spelling in the XAML; type exists in a different assembly version than referenced; type is internal/non-public so it is not visible from the local assembly.","solutions":["Check the XAML prefix declaration (xmlns:local=\"clr-namespace:Ns;assembly=Asm\") for typos in namespace and assembly name.","Add a project reference to the assembly containing the type so it is loaded into the AppDomain.","Verify the type is public and its name (including nested-type '+' syntax) is spelled correctly.","Confirm the referenced assembly version actually contains the type (rebuild or update package)."],"exampleFix":"<!-- before: assembly name wrong or missing -->\nxmlns:local=\"clr-namespace:MyApp.Controls;assembly=WrongAsm\"\n<!-- after -->\nxmlns:local=\"clr-namespace:MyApp.Controls;assembly=MyApp\"","handlingStrategy":"validation","validationCode":"// Before loading XAML, verify the referenced type resolves\nvar asm = Assembly.LoadFrom(\"MyApp.dll\");\nif (asm.GetType(\"MyApp.Controls.MyControl\") is null)\n    throw new InvalidOperationException(\"Referenced XAML type missing from assembly\");","typeGuard":"static bool TypeResolves(SchemaContext ctx, string prefix, string localName)\n    => ctx.GetXamlType(new XamlTypeName(prefix, localName))?.UnderlyingType is not null;","tryCatchPattern":"try { Resolve(typeName); }\ncatch (XamlParseException ex) when (ex.Message.Contains(\"was not found\"))\n{ /* log qualified name; hint at missing xmlns/assembly reference */ }","preventionTips":["Always declare xmlns mappings as clr-namespace=...;assembly=... with both parts spelled correctly.","Add project/package references for every assembly used in XAML.","Only expose public types to XAML.","Compile XAML (BAML) rather than runtime-parse where possible — the compiler catches unresolved types."],"tags":["wpf","xaml","type-resolution","not-found"],"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"}