I am working on one of the project to migrate from nopCommmerce 3.8 to nopCommerce 4.4. I am facing below issue, please help me to rectify it.
I have a controller called ' TEDPortalController
' where I have added methods from 3.8 related to 'TonerRequest'.
First it fired the below error :
DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Nop.Web.Controllers.TEDPortalController' can be invoked with the available services and parameters:
Cannot resolve parameter 'Nop.Services.TonerRequest.ITonerRequestService tonerRequestService' of constructor 'Void .ctor(Nop.Core.IWorkContext, Nop.Services.Logging.ILogger, Nop.Core.Events.IEventPublisher, Nop.Services.TonerRequest.ITonerRequestService)'.
Then I have added 2 lines in DependencyRegistrar.cs as :
services.AddScoped<ITonerRequestService, TonerRequestService>();
services.AddScoped<IEventPublisher, EventPublisher>();
After that I am getting below error :
DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Nop.Services.TonerRequest.TonerRequestService' can be invoked with the available services and parameters:
Cannot resolve parameter 'Nop.Core.Data.IRepository`1[Nop.Core.Domain.TonerRequest.TonerRequestMaster] tonerRequestMasterRepository' of constructor 'Void .ctor(Nop.Core.Data.IRepository`1[Nop.Core.Domain.TonerRequest.TonerRequestMaster], Nop.Core.Data.IRepository`1[Nop.Core.Domain.TonerRequest.TonerRequestDetails], Nop.Core.Events.IEventPublisher)'.
I think I need to add more lines into DependencyRegistrar.cs, but I am not able to get what needs to be add there. Request you to please help us to rectify this issue.
in Nopcommerce 4.4 you need to Register services into the IServiceCollection, inside NopStartup class in this way:
And You don't need to register IEventPublisher, you just need to call the name space Nop.Core.Events