None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type
'Umbraco.Core.Services.ContentService' can be invoked with the available services and parameters:Cannot resolve
parameter 'Umbraco.Core.Persistence.RepositoryFactory repositoryFactory' of constructor 'Void
.ctor(Umbraco.Core.Persistence.UnitOfWork.IDatabaseUnitOfWorkProvider, Umbraco.Core.Persistence.RepositoryFactory,
Umbraco.Core.Logging.ILogger, Umbraco.Core.Events.IEventMessagesFactory, Umbraco.Core.Publishing.IPublishingStrategy,
Umbraco.Core.Services.IDataTypeService, Umbraco.Core.Services.IUserService)'.
Which types do I register with my IOC to satisfy the dependencies of ContentService ?
Umbraco creates an instance of ContentService for you with the correct configuration.
Therefore, it's better to register this instance with Autofac by using RegisterInstance() instead of trying to register the ContentService type with RegisterType().
Which types to register with IOC container so ContentService can be instantiated
One of my classes depends on
IContentService
. I'm trying to provide anIContentService
to this class with an IOC container.Here is how I'm registering
IContentService
with my IOC (Autofac)However, Autofac doesn't know about every type
Umbraco.Core.Services.ContentService
needs to instantiate.I'm running into stack traces like this one:
Which types do I register with my IOC to satisfy the dependencies of
ContentService
?I've managed to find the right way to do this.
Umbraco creates an instance of ContentService for you with the correct configuration.
Therefore, it's better to register this instance with Autofac by using
RegisterInstance()
instead of trying to register theContentService
type withRegisterType()
.This way, Autofac won't try to instantiate
ContentService
itself - so it can't mess up the instantiation.is working on a reply...