{"record":{"id":"5011c9bf99d3a961","repo":"unoplatform/uno","slug":"type-0-is-not-resolved-as-a-valid-type-by-the","errorCode":null,"errorMessage":"Type '{0}' is not resolved as a valid type by the type resolver '{1}'.","messagePattern":"Type '(.+?)' is not resolved as a valid type by the type resolver '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Windows.Markup/TypeExtension.cs","lineNumber":93,"sourceCode":"\t\t\t{\n\t\t\t\tthrow new InvalidOperationException (\"Either TypeName or Type must be filled before calling ProvideValue method\");\n\t\t\t}\n\n\t\t\tif (serviceProvider == null) // it can be null when Type is supplied.\n\t\t\t{\n\t\t\t\tthrow new ArgumentNullException (\"serviceProvider\");\n\t\t\t}\n\n\t\t\tvar p = serviceProvider.GetService (typeof (IXamlTypeResolver)) as IXamlTypeResolver;\n\t\t\tif (p == null)\n\t\t\t{\n\t\t\t\tthrow new InvalidOperationException (\"serviceProvider does not provide IXamlTypeResolver service.\");\n\t\t\t}\n\n\t\t\tvar ret = p.Resolve (TypeName);\n\t\t\tif (ret == null)\n\t\t\t{\n\t\t\t\tthrow new InvalidOperationException (String.Format (CultureInfo.InvariantCulture, \"Type '{0}' is not resolved as a valid type by the type resolver '{1}'.\", TypeName, p.GetType ()));\n\t\t\t}\n\n\t\t\treturn ret;\n\t\t}\n\t}\n}\n","sourceCodeStart":75,"sourceCodeEnd":100,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Windows.Markup/TypeExtension.cs#L75-L100","documentation":"Thrown by TypeExtension.ProvideValue when the IXamlTypeResolver.Resolve(TypeName) call returns null, meaning the resolver could not map the type name string to any loaded Type. The message interpolates both the offending TypeName and the resolver's concrete type to aid diagnosis.","triggerScenarios":"TypeName references an unknown CLR namespace, a missing xmlns prefix, an assembly that is not loaded, or a typo in the type name. Resolve returns null instead of throwing, so ProvideValue surfaces the failure here.","commonSituations":"XAML with an undeclared xmlns prefix (e.g. local: used without xmlns:local=); type moved or renamed between versions; assembly not referenced at runtime; namespace mismatch between XAML and code-behind.","solutions":["Declare the xmlns prefix at the root element, e.g. xmlns:local=\"using:MyApp.Controls\".","Confirm the target type exists in a referenced assembly and the namespace matches.","Use assembly-qualified names if the type lives in a differently named assembly.","Check for typos and that the type is public (internal types need InternalsVisibleTo or the XAML schema context must allow internals)."],"exampleFix":"<!-- before -->\n<x:Type TypeName=\"local:MyControl\"/> <!-- local prefix not declared -->\n\n<!-- after -->\n<Page xmlns:local=\"using:MyApp.Controls\">\n  <x:Type TypeName=\"local:MyControl\"/>\n</Page>","handlingStrategy":"try-catch","validationCode":"// Pre-resolve the type name to give a clearer error\nvar resolver = (IXamlTypeResolver)sp.GetService(typeof(IXamlTypeResolver));\nif (resolver.Resolve(typeName) == null)\n    throw new InvalidOperationException($\"Type '{typeName}' not resolvable\");\nvar value = new TypeExtension { TypeName = typeName }.ProvideValue(sp);","typeGuard":"static bool IsTypeNameResolvable(IXamlTypeResolver r, string name)\n    => r?.Resolve(name) != null;","tryCatchPattern":"try\n{\n    var t = (Type)new TypeExtension { TypeName = name }.ProvideValue(ctx);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"is not resolved as a valid type\"))\n{\n    // log xmlns/assembly issue and fall back to Type.GetType(name)\n    t = Type.GetType(name);\n}","preventionTips":["Declare every xmlns prefix used in x:Type directives at the root element.","Keep type names stable across versions or update XAML when renaming.","Ensure referenced assemblies are loaded at runtime (especially under trimming/AOT)."],"tags":["xaml","markup-extension","type-extension","type-resolution","uno"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}