تخطَّ إلى المحتوى

Dependency not registered (ARCH502)

هذا المحتوى غير متوفر بلغتك بعد.

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).

public class OrdersController(IOrderExporter exporter) : ControllerBase { }
// Program.cs: nothing registers IOrderExporter
Program.cs
public class OrdersController(IOrderExporter exporter) : ControllerBase { }
builder.Services.AddScoped<IOrderExporter, CsvOrderExporter>();