When trying to activate a Controller I get the following error due to a service not properly injected:
System.InvalidOperationException: 'Unable to resolve service for type 'AnubisServer.Server.IDroneOperations' while attempting to activate 'AnubisServer.DroneController'.'
I have the following hierachy:
public interface IOperations { } public interface ICatalog : IOperations { } public interface IAdmin : ICatalog { } public interface ICatalogService : IAdmin, ISomethingElse { } In my startup i am providing a concrete implementation for the most derived interface ICatalogService:
Startup
public void ConfigureServices(IServiceCollection services) { services.AddMvc(); ICatalogService catalogService = new SomeConcreteService(); services.AddSingleton(catalogService); } Controller
public class CatalogController:Controller { private IOperations operations; public CatalogController(IOperations ops) { this.operations=ops; } } So I do not understand why it does not work to inject a base class interface since i am providing a derived concrete instance.
Any ideas?
services.AddSingleton<IOperations>(catalogService)