dotnet/maui · error · BuildException
XC0000
XC0000
Error message
Cannot resolve type "{0}". What it means
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.
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.
Example fix
<!-- before (typo: MyItemVeiw) --> <ContentPage xmlns:local="clr-namespace:MyApp.Views"> <DataTemplate TypeName="local:MyItemVeiw" /> </ContentPage> <!-- after --> <ContentPage xmlns:local="clr-namespace:MyApp.Views"> <DataTemplate TypeName="local:MyItemView" /> </ContentPage>
Defensive patterns
Strategy: validation
Validate before calling
// Validate that a type name referenced in DataTemplate TypeName resolves
static bool CanResolveType(string typeName, Assembly[] searchAssemblies)
=> searchAssemblies.SelectMany(a => a.GetTypes())
.Any(t => t.Name == typeName || t.FullName == typeName); Prevention
- 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.
When it happens
Trigger: 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'.
Common situations: 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.
Related errors
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/e62b19be44c44eac.
Report an issue: GitHub.
Appendix: source
Thrown at src/Controls/src/Build.Tasks/CompiledMarkupExtensions/DataTemplateExtension.cs:26
using static Mono.Cecil.Cil.OpCodes;
namespace Microsoft.Maui.Controls.Build.Tasks
{
class DataTemplateExtension : ICompiledMarkupExtension
{
public IEnumerable<Instruction> ProvideValue(ElementNode node, ModuleDefinition module, ILContext context, out TypeReference typeRef)
{
typeRef = module.ImportReference(context.Cache, ("Microsoft.Maui.Controls", "Microsoft.Maui.Controls", "DataTemplate"));
var name = new XmlName("", "TypeName");
if (!node.Properties.TryGetValue(name, out INode typeNameNode) && node.CollectionItems.Any())
typeNameNode = node.CollectionItems[0];
if (typeNameNode is not ValueNode valueNode)
throw new BuildException(BuildExceptionCode.PropertyMissing, node as IXmlLineInfo, null, "TypeName", typeof(Microsoft.Maui.Controls.Xaml.DataTemplateExtension));
var contentTypeRef = module.ImportReference(XmlTypeExtensions.GetTypeReference(context.Cache, valueNode.Value as string, module, node as BaseNode))
?? throw new BuildException(BuildExceptionCode.TypeResolution, node as IXmlLineInfo, null, valueNode.Value);
var dataTemplateCtor = module.ImportCtorReference(context.Cache, typeRef, new[] { module.ImportReference(context.Cache, ("mscorlib", "System", "Type")) });
return [
Create(Ldtoken, module.ImportReference(contentTypeRef)),
Create(Call, module.ImportMethodReference(context.Cache, ("mscorlib", "System", "Type"), methodName: "GetTypeFromHandle", parameterTypes: new[] { ("mscorlib", "System", "RuntimeTypeHandle") }, isStatic: true)),
Create(Newobj, dataTemplateCtor),
];
}
}
}
View on GitHub (pinned to f377ff1c5e)