I'm trying to register all implementations of my generic repository as follows:
container.Register(typeof(IRepository<>), new[] { typeof(Repository<>).Assembly });
However, the container can't verify my configuration:
Additional information: The configuration is invalid. Creating the instance for type IErrorLogService failed. The constructor of type ErrorLogService contains the parameter with name 'errorLogRepository' and type IRepository<ErrorLog> that is not registered. Please ensure IRepository<ErrorLog> is registered, or change the constructor of ErrorLogService. Note that there exists a registration for a different type Persistence.Interfaces.Repository.Generic.IRepository<T> while the requested type is Persistence.Interfaces.Repository.Generic.IRepository<Persistence.DataModel.ErrorLog>.
Based on various SO threads, the snippet above should be the way to go. What did I miss?
My repository class:
public class Repository<T> : IRepository<T> where T : Entity { }
IRepository
and Repository
exists in the same assembly.
An explicit registration of each type works:
container.Register<IRepository<ErrorLog>, Repository<ErrorLog>>();