{"record":{"id":"9a7d3fa19ca9d5fe","repo":"unoplatform/uno","slug":"unable-to-find-type-objectdefinition-type","errorCode":null,"errorMessage":"Unable to find type '{objectDefinition.Type}'","messagePattern":"Unable to find type '(.+?)'","errorType":"exception","errorClass":"XamlGenerationException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs","lineNumber":3497,"sourceCode":"\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tValidateName(value, member);\n\n\t\t\t\t\t\t\t\twriter.AppendLineIndented($@\"__nameScope.RegisterName(\"\"{value}\"\", {writer.AppliedParameterName});\");\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tmember.Member.Name == \"Name\"\n\t\t\t\t\t\t\t\t&& !IsAttachedProperty(member)\n\t\t\t\t\t\t\t\t&& !isMemberInsideResourceDictionary.isInside\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tnameMember = member;\n\n\t\t\t\t\t\t\t\tvar type = FindType(objectDefinition.Type)?.GetFullyQualifiedTypeIncludingGlobal();\n\n\t\t\t\t\t\t\t\tif (type == null)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tthrow new XamlGenerationException($\"Unable to find type '{objectDefinition.Type}'\", objectDefinition);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\twriter.AppendLineInvariantIndented(\"__that.{0} = {1};\", value, writer.AppliedParameterName);\n\t\t\t\t\t\t\t\t// value is validated as non-null in ValidateName call above.\n\t\t\t\t\t\t\t\tRegisterBackingField(type, value!, FindObjectFieldAccessibility(objectDefinition));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if (member.Member.Name == \"Name\"\n\t\t\t\t\t\t\t\t&& member.Member.PreferredXamlNamespace == XamlConstants.XamlXmlNamespace)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\twriter.AppendLineInvariantIndented(\"// x:Name {0}\", member.Value, member.Value);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if (member.Member.Name == \"Key\")\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\twriter.AppendLineInvariantIndented(\"// Key {0}\", member.Value, member.Value);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if (member.Member.Name == \"DeferLoadStrategy\"\n\t\t\t\t\t\t\t\t&& member.Member.PreferredXamlNamespace == XamlConstants.XamlXmlNamespace)\n\t\t\t\t\t\t\t{","sourceCodeStart":3479,"sourceCodeEnd":3515,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs#L3479-L3515","documentation":"Thrown when processing an x:Name member (line 3490 branch): the generator needs the object's type symbol to register a backing field (RegisterBackingField), but FindType(objectDefinition.Type) returns null. This differs from 309 — here the object passed earlier checks but specifically the Name-backing-field registration requires a resolvable type and it is missing.","triggerScenarios":"An element with x:Name whose type cannot be resolved by the compilation (undeclared xmlns, missing assembly reference, typo); an element inside a ResourceDictionary that also has x:Name but whose type is unknown.","commonSituations":"Naming a control whose type comes from an unreferenced assembly; renaming/moving a control type without updating xmlns; platform-conditional types referenced on a TFM where they don't exist.","solutions":["Resolve the type exactly as for error 309: fix the xmlns prefix, add the project/PackageReference, correct any typo.","Confirm the element's type compiles on the current UnoTargetFrameworkOverride (TFM).","Remove the x:Name if the element type is intentionally unresolved/optional, or gate the XAML by platform."],"exampleFix":"<!-- before -->\n<Page xmlns:w=\"using:Missing.Lib\">\n  <w:BadControl x:Name=\"MyControl\"/>\n</Page>\n\n<!-- after -->\n<Page xmlns:w=\"using:Real.Lib\">\n  <w:RealControl x:Name=\"MyControl\"/>\n</Page>","handlingStrategy":"validation","validationCode":"# Same as 309: ensure every type used in XAML resolves. Additionally, list x:Name'd elements\n# and confirm their types compile:\nGet-ChildItem -Recurse -Filter *.xaml | ForEach-Object {\n  Select-String -Path $_.FullName -Pattern '<(\\w+:)?([\\w.]+)\\b[^>]*x:Name' |\n    ForEach-Object { Write-Host \"Named element of type: $($_.Matches[0].Groups[2].Value)\" }\n# Then build and resolve any CS0246 alongside the XAML error.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve type-resolution issues (see 309) before adding x:Name.","Confirm the type exists on the target TFM when cross-targeting."],"tags":["xaml","type-resolution","x-name","build"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}