A loader needs a service nobody registered

A loader's constructor asks for a service that is not registered at build time.

  • Error
  • BEVEL043

What it means

Services registered only in Program.cs are not available during the build. Loaders run during the build, so they cannot see them.

Example message

text
Data/Posts/BlogPost.cs(6,15): error BEVEL043: Loader 'MySite.Data.PostLoader' requires a service of type 'MySite.Data.IClock' (constructor parameter 'clock') that is not registered at build time. Register it in your IBevelDataStartup.ConfigureServices (e.g. from the shared AddXxx method your Program.cs also calls); services configured only in Program.cs are not available at build time. Help: https://khalidabuhakmeh.github.io/bevel/reference/diagnostics/bevel043/

How to fix

Register the service in your startup. Share one AddXxx method between Program.cs and the startup so they never drift apart.

Data/Startup.cscsharp
public sealed class Startup : IBevelDataStartup
{
    public void ConfigureServices(IServiceCollection services, IConfiguration config)
        => services.AddSingleton<IClock, SystemClock>();
}