Dependency not registered (ARCH502)
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Key dotnet.di.unregistered-dependency · Severity error · Category di
Flags a constructor dependency of a class the container builds (controllers, hosted services, MediatR handlers, registered services) when nothing in the solution registers it. The first request that needs the class fails with ‘Unable to resolve service for type’. Only the repository’s own interfaces and abstract classes are checked; the check stands down when the solution registers services by convention (assembly scanning).
Incorrect
Section titled “Incorrect”public class OrdersController(IOrderExporter exporter) : ControllerBase { }
// Program.cs: nothing registers IOrderExporterCorrect
Section titled “Correct”public class OrdersController(IOrderExporter exporter) : ControllerBase { }
builder.Services.AddScoped<IOrderExporter, CsvOrderExporter>();