Little bit new to NopCommerce MVC (Working on 2.40) and having problems with a newly created plugin (though already did some work on Plugins and never had this problem earlier).
No parameterless constructor defined for this object.
Trying to create a new plugin for NopCommerce 2.40 which will be responsible to keep the information for the images to show on the Home page for web application.
two tables are involved. All the Controllers, services and other stuff created but having the above error.
Also added the Interface and class mapping in Dependency registrar as :
//define the dependency between the Service And Interface Register.
builder.RegisterType<RotatorService>().As<IRotatorService>().InstancePerHttpRequest();
//data layer
var dataSettingsManager = new DataSettingsManager();
var dataProviderSettings = dataSettingsManager.LoadSettings();
if (dataProviderSettings != null && dataProviderSettings.IsValid())
{
//register named context
builder.Register<IDbContext>(c => new RotatorObjectContext(dataProviderSettings.DataConnectionString))
.Named<IDbContext>("nop_object_context_Rotator")
.InstancePerHttpRequest();
builder.Register(c => new RotatorObjectContext(dataProviderSettings.DataConnectionString))
.InstancePerHttpRequest();
}
else
{
//register named context
builder.Register<IDbContext>(c => new RotatorObjectContext(c.Resolve<DataSettings>().DataConnectionString))
.Named<IDbContext>("nop_object_context_Rotator")
.InstancePerHttpRequest();
builder.Register(c => new RotatorObjectContext(c.Resolve<DataSettings>().DataConnectionString))
.InstancePerHttpRequest();
}
//override required repository with our custom context
builder.RegisterType<EfRepository<RotatorManager>>()
.As<IRepository<RotatorManager>>()
.WithParameter(ResolvedParameter.ForNamed<IDbContext>("nop_object_context_Rotator"))
.InstancePerHttpRequest();
builder.RegisterType<EfRepository<RotatorSlidesManager>>()
.As<IRepository<RotatorSlidesManager>>()
.WithParameter(ResolvedParameter.ForNamed<IDbContext>("nop_object_context_Rotator"))
.InstancePerHttpRequest();
Here RotatorService and IRotatorService are class and Interface respectivelly.
my controller's constructor code is as:
public HomePageRotatorAdminController(IRotatorService rotatorService, ILocalizationService localizationService)
{
this._rotatorService = rotatorService;
this._localizationService = localizationService;
}
Already did this in other new plugins but never struck but might be there is something wrong in the code and i am not able to track that.
error is coming when i am adding the Parametrized constructor in the controller.
Any type of help will be appriciated.
Thanks and regards