Add new service Paremeter in common controller

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
I have created new service class in nop.services project. I have to access this service object in common controller constructors.

For example.

private readonly ItestService _testservice;

public CommonController(ICategoryService categoryService, IProductService productService,
            IManufacturerService manufacturerService, ITopicService topicService,
            ILanguageService languageService,
            ICurrencyService currencyService, ILocalizationService localizationService,
            IWorkContext workContext,
            IQueuedEmailService queuedEmailService, IEmailAccountService emailAccountService,
            ISitemapGenerator sitemapGenerator, IThemeContext themeContext,
            IThemeProvider themeProvider, IForumService forumService,
            ICustomerService customerService, IWebHelper webHelper,
            IPermissionService permissionService, IMobileDeviceHelper mobileDeviceHelper,
            HttpContextBase httpContext, CustomerSettings customerSettings,
            TaxSettings taxSettings, CatalogSettings catalogSettings,
            StoreInformationSettings storeInformationSettings, EmailAccountSettings emailAccountSettings,
            CommonSettings commonSettings, BlogSettings blogSettings, ForumSettings forumSettings,
            LocalizationSettings localizationSettings, CaptchaSettings captchaSettings, ItestService testservice){
          
                .
                .
                .
                this._testservice= testservice;
                .
                .
                .

}

When I run project, I am getting following errors.

No parameterless constructor defined for this object.

Can anybody help me to resolve this error? How can I add more parameters in controller constructors?

Thanks
Imrankhan
12 years ago
Did you register the new service in Nop.Web.Framework.DependencyRegistrar?
12 years ago
Thank you for your reply.

I register new service and its working now.

Can you please let me know how and from where DependecyRegister class is called when controller class execute.

Thanks
Imrankhan
12 years ago
It's called when the application starts up the first time.  The app uses those rules to know what class to inject when you reference an interface in your constructor.
8 years ago
AndyMcKenna wrote:
It's called when the application starts up the first time.  The app uses those rules to know what class to inject when you reference an interface in your constructor.


is it defined somewhere in the global.asax or any config file? i cant find it. thanks
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.