{"record":{"id":"bf7f04537f869f98","repo":"unoplatform/uno","slug":"serviceprovider-does-not-provide-ixamltyperesolver","errorCode":null,"errorMessage":"serviceProvider does not provide IXamlTypeResolver service.","messagePattern":"serviceProvider does not provide IXamlTypeResolver service\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Windows.Markup/TypeExtension.cs","lineNumber":87,"sourceCode":"\t\t\tif (Type != null)\n\t\t\t{\n\t\t\t\treturn Type;\n\t\t\t}\n\n\t\t\tif (TypeName == null)\n\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":69,"sourceCodeEnd":100,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Windows.Markup/TypeExtension.cs#L69-L100","documentation":"Thrown by TypeExtension.ProvideValue when the service provider does not return an IXamlTypeResolver from GetService. The resolver is mandatory to map the TypeName string to a System.Type; without it string-based type resolution cannot proceed.","triggerScenarios":"Calling ProvideValue with a provider whose GetService(typeof(IXamlTypeResolver)) returns null, e.g. a minimal mock or a context that only supplies other services.","commonSituations":"Custom XAML pipelines that omit the type resolver; test stubs; reusing a provider from a different markup extension that does not need type resolution.","solutions":["Use the standard XamlObjectWriter/XamlXmlReader context which supplies IXamlTypeResolver.","In tests, provide a fake provider returning a IXamlTypeResolver for the requested service type.","Set the Type property to bypass resolver-based resolution entirely."],"exampleFix":"// before\nvar ext = new TypeExtension { TypeName = \"local:MyControl\" };\nvar v = ext.ProvideValue(minimalProvider); // throws\n\n// after\nvar ext = new TypeExtension { TypeName = \"local:MyControl\" };\nvar v = ext.ProvideServiceWith<XamlTypeResolver>(resolver => ext.ProvideValue(ctx));","handlingStrategy":"validation","validationCode":"public static bool HasTypeResolver(IServiceProvider sp)\n    => sp?.GetService(typeof(IXamlTypeResolver)) is IXamlTypeResolver;\n\nif (!HasTypeResolver(sp))\n    throw new InvalidOperationException(\"IXamlTypeResolver missing\");\nvar value = new TypeExtension { TypeName = \"local:Foo\" }.ProvideValue(sp);","typeGuard":"static bool HasTypeResolver(IServiceProvider sp)\n    => sp?.GetService(typeof(IXamlTypeResolver)) is IXamlTypeResolver;","tryCatchPattern":null,"preventionTips":["Use the standard XamlObjectWriter context which supplies IXamlTypeResolver.","In tests, provide a fake provider returning a IXamlTypeResolver.","Set Type directly to avoid the resolver dependency."],"tags":["xaml","markup-extension","type-extension","service-provider","uno"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}