Close

An error occurred when trying to create a controller of type 'SevenSpikes.Nop.Plugins.AjaxFilters.Controllers.Catalog7SpikesController'. Make sure that the controller has a parameterless public constructor.

ranjith888999
6 years ago
#14275 Quote
Avatar
  • 3
Hi, I Just Installed SevenSpikes.Nop.Plugins.AjaxFilters and SevenSpikes.Core when i am using the Filters i am getting an error stating "Loading the page failed" and in the log file the error shown is "An error occurred when trying to create a controller of type 'SevenSpikes.Nop.Plugins.AjaxFilters.Controllers.Catalog7SpikesController'. Make sure that the controller has a parameterless public constructor".Can anyone let me know how to fix this issue
SDobrev
6 years ago
#14276 Quote
Avatar
  • Moderator
  • 283
Hi,

Have you made any changes to the constructors of the nopCommerce controllers? If you have please use property injection instead of constructor injection.
Best Regards,
Stoyan Dobrev
Nop-Templates.com
ranjith888999
6 years ago
#14280 Quote
Avatar
  • 3
Hi, Thanks for your response can you please let me know how to use property injection  in detail with an example.However i didnot made any changes to the constructors of the nopCommerce controllers
SDobrev
6 years ago
#14281 Quote
Avatar
  • Moderator
  • 283
Hi,

Here is an example:

private IMyService _myService;

public IMyService MyService
{
    get
    {
        if (_myService == null)
        {
            _myService = EngineContext.Current.Resolve<IMyService>();
        }

        return _myService;
    }
}
Best Regards,
Stoyan Dobrev
Nop-Templates.com
ranjith888999
6 years ago
#14317 Quote
Avatar
  • 3
Hi, i just added some extra methods to the productsservice file so do i need to implement the property injection in Products related files
SDobrev
6 years ago
#14318 Quote
Avatar
  • Moderator
  • 283
Hi,

There are no problems if you have added new methods.

If you have modified the constructor of the ProductService you should revert your changes and resolve the dependencies using property injection.
Best Regards,
Stoyan Dobrev
Nop-Templates.com