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 anIContentServiceto this class with an IOC container.Here is how I'm registering
IContentServicewith my IOC (Autofac)However, Autofac doesn't know about every type
Umbraco.Core.Services.ContentServiceneeds 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 theContentServicetype withRegisterType().This way, Autofac won't try to instantiate
ContentServiceitself - so it can't mess up the instantiation.is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.