InvalidOperationException: Cannot provide a value for property 'Clock' on type 'FixLab.Components.Pages.Home'. There is no registered service of type 'FixLab.Services.IClock'. means the page asks for a service with @inject that was never registered. Register it in Program.cs and the page renders.

The fix is one line before builder.Build(), for example builder.Services.AddScoped<IClock, SystemClock>();. The property name and the type in the message tell you exactly which injection failed.

The error

fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
      An unhandled exception has occurred while executing the request.
      System.InvalidOperationException: Cannot provide a value for property 'Clock' on type 'FixLab.Components.Pages.Home'. There is no registered service of type 'FixLab.Services.IClock'.
         at Microsoft.AspNetCore.Components.ComponentFactory.<>c__DisplayClass11_0.<CreatePropertyInjector>g__Initialize|1(IServiceProvider serviceProvider, IComponent component)
         at Microsoft.AspNetCore.Components.ComponentFactory.InstantiateComponent(IServiceProvider serviceProvider, Type componentType, IComponentRenderMode callerSpecifiedRenderMode, Nullable`1 parentComponentId)

That is the top of the console log; the browser got an HTTP 500 for the page.

Why it happens

@inject IClock Clock does not create anything. It compiles to a property marked [Inject], and when Blazor creates the component its component factory asks the dependency injection container for an IClock to put in that property. The container only knows the types you registered on builder.Services. Here the interface and its class existed, the page compiled, and nothing told the container which class to hand out, so the factory threw before the component's first lifecycle method ran.

That timing is why the stack trace points at ComponentFactory rather than at your code: the failure is in creating the component, not in using the service. It is the Blazor counterpart of the "Unable to resolve service for type" error you get with constructor injection in a controller or a minimal API.

The fix

Register the service in Program.cs:

using FixLab.Components;
using FixLab.Services;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddRazorComponents()
    .AddInteractiveServerComponents();

builder.Services.AddScoped<IClock, SystemClock>();

var app = builder.Build();

The page, unchanged, now renders (status line and the line that uses the service):

HTTP/1.1 200 OK
<p>Loaded at 13:56</p>

Pick the lifetime that fits the service. AddScoped gives one instance per request for statically rendered pages and one per circuit for interactive server pages; a stateless service like this clock would be just as happy with AddSingleton. If the solution has a separate .Client project, register the service in every Program.cs that renders the component.

How it was reproduced

A fresh Blazor Web App from dotnet new blazor -n FixLab -int Server on .NET SDK 10.0.401 with the ASP.NET Core 10.0.12 runtime. A small IClock interface and SystemClock class went into Services/IClock.cs, and Home.razor got @using FixLab.Services and @inject IClock Clock. Running the app with dotnet run --urls http://localhost:15480 and requesting / returned 500 with the error above in the console. After the AddScoped line the same request returned 200 and the time.

Frequently asked

What does there is no registered service of type mean in Blazor?
A component uses @inject for a type the dependency injection container does not know. Add a registration such as builder.Services.AddScoped<IMyService, MyService>() in Program.cs before builder.Build().
Where do I register services for Blazor components?
In Program.cs, on builder.Services, before var app = builder.Build(). In a Blazor Web App with a separate Client project, register it in each Program.cs that renders the component.
Should a Blazor service be scoped, singleton or transient?
Scoped is the usual choice: one instance per request for static pages and per circuit for interactive server pages. Use singleton only for stateless or thread-safe services shared by all users, and transient for cheap objects that need a fresh instance each time.

More decoded errors in the Fixes category. For lifetimes and how services reach components, see Services and Dependency Injection in Blazor.