{"record":{"id":"e62b19be44c44eac","repo":"dotnet/maui","slug":"xc0000-e62b19","errorCode":"XC0000","errorMessage":"Cannot resolve type \"{0}\".","messagePattern":"Cannot resolve type \"(.+?)\"\\.","errorType":"exception","errorClass":"BuildException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/Build.Tasks/CompiledMarkupExtensions/DataTemplateExtension.cs","lineNumber":26,"sourceCode":"using static Mono.Cecil.Cil.OpCodes;\n\nnamespace Microsoft.Maui.Controls.Build.Tasks\n{\n\tclass DataTemplateExtension : ICompiledMarkupExtension\n\t{\n\t\tpublic IEnumerable<Instruction> ProvideValue(ElementNode node, ModuleDefinition module, ILContext context, out TypeReference typeRef)\n\t\t{\n\t\t\ttypeRef = module.ImportReference(context.Cache, (\"Microsoft.Maui.Controls\", \"Microsoft.Maui.Controls\", \"DataTemplate\"));\n\t\t\tvar name = new XmlName(\"\", \"TypeName\");\n\n\t\t\tif (!node.Properties.TryGetValue(name, out INode typeNameNode) && node.CollectionItems.Any())\n\t\t\t\ttypeNameNode = node.CollectionItems[0];\n\n\t\t\tif (typeNameNode is not ValueNode valueNode)\n\t\t\t\tthrow new BuildException(BuildExceptionCode.PropertyMissing, node as IXmlLineInfo, null, \"TypeName\", typeof(Microsoft.Maui.Controls.Xaml.DataTemplateExtension));\n\n\t\t\tvar contentTypeRef = module.ImportReference(XmlTypeExtensions.GetTypeReference(context.Cache, valueNode.Value as string, module, node as BaseNode))\n\t\t\t\t?? throw new BuildException(BuildExceptionCode.TypeResolution, node as IXmlLineInfo, null, valueNode.Value);\n\n\t\t\tvar dataTemplateCtor = module.ImportCtorReference(context.Cache, typeRef, new[] { module.ImportReference(context.Cache, (\"mscorlib\", \"System\", \"Type\")) });\n\t\t\treturn [\n\t\t\t\tCreate(Ldtoken, module.ImportReference(contentTypeRef)),\n\t\t\t\tCreate(Call, module.ImportMethodReference(context.Cache, (\"mscorlib\", \"System\", \"Type\"), methodName: \"GetTypeFromHandle\", parameterTypes: new[] { (\"mscorlib\", \"System\", \"RuntimeTypeHandle\") }, isStatic: true)),\n\t\t\t\tCreate(Newobj, dataTemplateCtor),\n\t\t\t];\n\t\t}\n\t}\n}\n","sourceCodeStart":8,"sourceCodeEnd":37,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Build.Tasks/CompiledMarkupExtensions/DataTemplateExtension.cs#L8-L37","documentation":"XC0000 TypeResolution thrown by the DataTemplateExtension compiled markup extension when the type named in the TypeName property cannot be resolved to a .NET type. After extracting the type-name string from the ValueNode, the extension calls XmlTypeExtensions.GetTypeReference. If this returns null (type not found in any referenced assembly or declared XML namespace), the build fails.","triggerScenarios":"Specifying a TypeName value that does not resolve: a misspelled type name, a type in an undeclared XML namespace prefix, or a type that exists in an assembly not referenced by the project. Example: TypeName='local:MyItemVeiw' (typo), TypeName='NonExistentType'.","commonSituations":"Typo in the type name. Missing or wrong xmlns:local declaration. The type was renamed or moved to a different namespace. The assembly containing the type is not added as a project reference. Using a type name without a namespace prefix when it is not in the default namespace.","solutions":["Verify the type name is spelled correctly and matches the actual class name.","Ensure the XML namespace prefix (e.g. 'local:') is declared at the root element and maps to the correct CLR namespace and assembly.","Confirm the assembly containing the type is referenced by the project.","If the type was renamed/moved, update the TypeName value to match the new fully-qualified name."],"exampleFix":"<!-- before (typo: MyItemVeiw) -->\n<ContentPage xmlns:local=\"clr-namespace:MyApp.Views\">\n  <DataTemplate TypeName=\"local:MyItemVeiw\" />\n</ContentPage>\n\n<!-- after -->\n<ContentPage xmlns:local=\"clr-namespace:MyApp.Views\">\n  <DataTemplate TypeName=\"local:MyItemView\" />\n</ContentPage>","handlingStrategy":"validation","validationCode":"// Validate that a type name referenced in DataTemplate TypeName resolves\nstatic bool CanResolveType(string typeName, Assembly[] searchAssemblies)\n    => searchAssemblies.SelectMany(a => a.GetTypes())\n           .Any(t => t.Name == typeName || t.FullName == typeName);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Double-check type name spelling in TypeName attributes.","Ensure the XML namespace prefix maps to the correct CLR namespace and assembly.","Verify the project references the assembly containing the target type."],"tags":["xaml","maui","xamlc","markup-extension","datatemplate","type-resolution","build-time"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}