{"record":{"id":"42d303706a8ecd14","repo":"dotnet/aspnetcore","slug":"cannot-provide-a-value-for-property-propertyname-42d303","errorCode":null,"errorMessage":"Cannot provide a value for property '{propertyName}' on type '{type.FullName}'. There is no registered service of type '{propertyType}'.","messagePattern":"Cannot provide a value for property '(.+?)' on type '(.+?)'\\. There is no registered service of type '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Components/Components/src/DefaultComponentPropertyActivator.cs","lineNumber":97,"sourceCode":"                if (serviceKey is not null)\n                {\n                    if (serviceProvider is not IKeyedServiceProvider keyedServiceProvider)\n                    {\n                        throw new InvalidOperationException($\"Cannot provide a value for property \" +\n                            $\"'{propertyName}' on type '{type.FullName}'. The service provider \" +\n                            $\"does not implement '{nameof(IKeyedServiceProvider)}' and therefore \" +\n                            $\"cannot provide keyed services.\");\n                    }\n\n                    serviceInstance = keyedServiceProvider.GetKeyedService(propertyType, serviceKey)\n                        ?? throw new InvalidOperationException($\"Cannot provide a value for property \" +\n                        $\"'{propertyName}' on type '{type.FullName}'. There is no \" +\n                        $\"registered keyed service of type '{propertyType}' with key '{serviceKey}'.\");\n                }\n                else\n                {\n                    serviceInstance = serviceProvider.GetService(propertyType)\n                        ?? throw new InvalidOperationException($\"Cannot provide a value for property \" +\n                        $\"'{propertyName}' on type '{type.FullName}'. There is no \" +\n                        $\"registered service of type '{propertyType}'.\");\n                }\n\n                setter.SetValue(component, serviceInstance);\n            }\n        }\n    }\n}\n","sourceCodeStart":79,"sourceCodeEnd":107,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/Components/Components/src/DefaultComponentPropertyActivator.cs#L79-L107","documentation":"Thrown by DefaultComponentPropertyActivator when a component property uses [Inject] (non-keyed) and no service of the property's type is registered in DI. GetService returns null and the exception fires at DefaultComponentPropertyActivator.cs:96-99. This is the most common Blazor DI error — a missing service registration.","triggerScenarios":"A Blazor component with [Inject] public IMyService Service { get; set; } where IMyService was never registered (or registered in the wrong DI container/scope).","commonSituations":"Forgetting to call services.AddSingleton/Scoped/Transient for a service used by a component; registering in a different scope (e.g., scoped in a non-circuit host); typo in the interface type; missing an extension method call like AddHttpClient.","solutions":["Register the service in Program.cs / Startup: services.AddScoped<IMyService, MyService>().","Verify the lifetime/scope matches the hosting model (Blazor Server uses scoped per-circuit; WASM uses singleton/scoped in client).","Check for typos in the interface or that the correct assembly is referenced."],"exampleFix":"// before\n// component: [Inject] public IWeatherService Weather { get; set; }\n// Program.cs: (nothing registered)\n\n// after\nbuilder.Services.AddScoped<IWeatherService, WeatherService>();","handlingStrategy":"validation","validationCode":"if (serviceProvider.GetService(propertyType) is null)\n    throw new InvalidOperationException($\"No registered service of type {propertyType}.\");","typeGuard":"static bool IsRegistered(IServiceProvider sp, Type t) => sp.GetService(t) is not null;","tryCatchPattern":null,"preventionTips":["Register all injected services in Program.cs with the correct lifetime.","Add a startup validation pass that resolves each [Inject]-decorated service type."],"tags":["blazor","di","injection","registration"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}