{"record":{"id":"9e4e269e2a14421a","repo":"unoplatform/uno","slug":"the-type-objectdefinition-type-could-not-be-fo","errorCode":null,"errorMessage":"The type '{objectDefinition.Type}' could not be found","messagePattern":"The type '(.+?)' could not be found","errorType":"exception","errorClass":"XamlGenerationException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs","lineNumber":3254,"sourceCode":"\n\t\tprivate void BuildExtendedProperties(IIndentedStringBuilder outerwriter, XamlObjectDefinition objectDefinition, bool useGenericApply = false)\n\t\t{\n\t\t\t_generatorContext.CancellationToken.ThrowIfCancellationRequested();\n\n\t\t\tTryAnnotateWithGeneratorSource(outerwriter);\n\t\t\tvar objectUid = GetObjectUid(objectDefinition);\n\n\t\t\tvar extendedProperties = GetExtendedProperties(objectDefinition);\n\t\t\tvar hasChildrenWithPhase = HasChildrenWithPhase(objectDefinition);\n\t\t\tvar objectDefinitionType = FindType(objectDefinition.Type);\n\t\t\tvar isFrameworkElement = IsType(objectDefinitionType, Generation.FrameworkElementSymbol.Value);\n\t\t\tvar hasIsParsing = HasIsParsing(objectDefinitionType);\n\n\t\t\tif (extendedProperties.Any() || hasChildrenWithPhase || isFrameworkElement || hasIsParsing || !objectUid.IsNullOrEmpty())\n\t\t\t{\n\t\t\t\tif (!useGenericApply && objectDefinitionType is null)\n\t\t\t\t{\n\t\t\t\t\tthrow new XamlGenerationException($\"The type '{objectDefinition.Type}' could not be found\", objectDefinition);\n\t\t\t\t}\n\n\t\t\t\tusing (var writer = CreateApplyBlock(outerwriter, objectDefinition))\n\t\t\t\t{\n\t\t\t\t\tXamlMemberDefinition? uidMember = null;\n\t\t\t\t\tXamlMemberDefinition? nameMember = null;\n\t\t\t\t\tComponentDefinition? componentDefinition = null;\n\t\t\t\t\tstring? uiAutomationId = null;\n\t\t\t\t\tstring[]? extractionTargetMembers = null;\n\n\t\t\t\t\tif (_isUiAutomationMappingEnabled)\n\t\t\t\t\t{\n\t\t\t\t\t\t// Look up any potential UI automation member mappings available for the current object definition\n\t\t\t\t\t\textractionTargetMembers = _uiAutomationMappings\n\t\t\t\t\t\t\t?.FirstOrDefault(m => _metadataHelper.FindTypeByFullName(m.Key) is INamedTypeSymbol mappingKeySymbol && (IsType(objectDefinitionType, mappingKeySymbol) || IsImplementingInterface(objectDefinitionType, mappingKeySymbol)))\n\t\t\t\t\t\t\t.Value\n\t\t\t\t\t\t\t?.ToArray() ?? [];\n\t\t\t\t\t}","sourceCodeStart":3236,"sourceCodeEnd":3272,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs#L3236-L3272","documentation":"Thrown in the apply-block builder when an object has traits requiring special initialization (extended properties, phasing, is a FrameworkElement, has IsParsing, or has an x:Uid) AND useGenericApply is false AND FindType cannot resolve the object's type. The generator needs the real type symbol to emit the apply block, so an unresolvable type here is fatal. The objectDefinition.Type string is whatever the XAML declared.","triggerScenarios":"Referencing a type in XAML whose xmlns prefix is undeclared or maps to an assembly not referenced; a typo in a type name; a custom control whose containing project/assembly is not referenced by the XAML's project.","commonSituations":"Adding a custom control without a project reference; wrong xmlns:local URI; a control moved/renamed between Uno versions; conditional compilation removing a type from a target where the XAML still references it.","solutions":["Verify the xmlns prefix for the type resolves to the correct namespace URI and that the assembly is referenced by the project.","Fix any typo in the type name in the XAML.","Add the missing project/PackageReference that contains the type.","If the type is platform-specific, gate the XAML or use ApiExtensibility/OperatingSystem.Is* so it exists on the target TFM."],"exampleFix":"<!-- before -->\n<Page xmlns:ctrl=\"using:WrongNamespace\">\n  <ctrl:MyWidget/>\n</Page>\n\n<!-- after -->\n<Page xmlns:ctrl=\"using:MyApp.Controls\">\n  <ctrl:MyWidget/>\n</Page>","handlingStrategy":"validation","validationCode":"# Cross-check xmlns prefixes map to referenced assemblies/types\n# (best done by building the project — Roslyn reports CS0246 for unresolvable types)\n# Pre-check: list xmlns declarations and verify the using-clause namespaces exist\nGet-ChildItem -Recurse -Filter *.xaml | ForEach-Object {\n  Select-String -Path $_.FullName -Pattern 'xmlns:(\\w+)=\"(?:using:|clr-namespace:)([^\"]+)\"' |\n    ForEach-Object { Write-Host \"prefix $($_.Matches[0].Groups[1].Value) -> $($_.Matches[0].Groups[2].Value)\" }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add the project/PackageReference for any custom control before referencing it in XAML.","Keep xmlns prefixes consistent and the using: namespace accurate.","When targeting a single TFM via UnoTargetFrameworkOverride, confirm the type exists on that TFM."],"tags":["xaml","type-resolution","xmlns","build"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}