{"record":{"id":"c425b76e64d76df2","repo":"dotnet/maui","slug":"xc0000-c425b7","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/TypeExtension.cs","lineNumber":33,"sourceCode":"\t\t{\n\t\t\tmemberRef = module.ImportReference(context.Cache, (\"mscorlib\", \"System\", \"Type\"));\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 ValueNode valueNode))\n\t\t\t\tthrow new BuildException(BuildExceptionCode.PropertyMissing, node as IXmlLineInfo, null, \"TypeName\", typeof(Microsoft.Maui.Controls.Xaml.TypeExtension));\n\n\t\t\tif (!node.Properties.ContainsKey(name))\n\t\t\t{\n\t\t\t\tnode.Properties[name] = typeNameNode;\n\t\t\t\tnode.CollectionItems.Clear();\n\t\t\t}\n\n\t\t\tvar typeref = module.ImportReference(XmlTypeExtensions.GetTypeReference(context.Cache, valueNode.Value as string, module, node as BaseNode));\n\n\t\t\tcontext.TypeExtensions[node] = typeref ?? throw new BuildException(BuildExceptionCode.TypeResolution, node as IXmlLineInfo, null, valueNode.Value);\n\n\t\t\treturn new List<Instruction> {\n\t\t\t\tCreate(Ldtoken, module.ImportReference(typeref)),\n\t\t\t\tCreate(Call, module.ImportMethodReference(context.Cache, (\"mscorlib\", \"System\", \"Type\"),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  methodName: \"GetTypeFromHandle\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  parameterTypes: [(\"mscorlib\", \"System\", \"RuntimeTypeHandle\")],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  isStatic: true)),\n\t\t\t};\n\t\t}\n\t}\n}","sourceCodeStart":15,"sourceCodeEnd":44,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Build.Tasks/CompiledMarkupExtensions/TypeExtension.cs#L15-L44","documentation":"Thrown by x:Type when the type name string was provided but XmlTypeExtensions.GetTypeReference returned null, meaning no matching type could be located in the referenced assemblies. The compiler emits a GetTypeFromHandle token, so it must have a real TypeReference.","triggerScenarios":"Typo in the type or namespace; missing xmlns prefix mapping; the assembly containing the type is not referenced by the project; the type is internal and not visible; using a type from an assembly that is loaded only at runtime.","commonSituations":"Refactor renamed a class/namespace but XAML was not updated; referenced a type in a project not added as a ProjectReference/PackageReference; xmlns uses the wrong clr-namespace or assembly name; type exists in a platform-specific assembly not included for the active target.","solutions":["Check the xmlns declaration: clr-namespace must match exactly and the assembly name must be correct.","Add the missing ProjectReference or PackageReference that contains the type.","Rebuild after renaming to refresh the cache, and correct the spelling/namespace.","If the type is internal, make it public or grant InternalsVisibleTo.","Confirm the type exists for the current target framework (not a platform-only type used in shared XAML)."],"exampleFix":"// before\nxmlns:local=\"clr-namespace:MyApp.Controlz\"\n<x:Type TypeName=\"local:MyView\" />\n// after\nxmlns:local=\"clr-namespace:MyApp.Controls\"\n<x:Type TypeName=\"local:MyView\" />","handlingStrategy":"validation","validationCode":"// Resolve the type the same way the compiler will, before building\nstatic bool TypeIsReferenceable(string xmlNamespace, string typeName, IEnumerable<Assembly> refs) {\n    var full = $\"{xmlNamespace}:{typeName}\";\n    return refs.SelectMany(a => a.GetTypes()).Any(t => t.FullName == typeName || t.Name == typeName);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add all needed ProjectReference/PackageReference before referencing types in XAML.","Keep xmlns clr-namespace and assembly attributes in sync with renames.","Rebuild after refactors to surface stale type references early."],"tags":["xaml","xamlc","x-type","type-resolution","references","build-time"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}