Reputation: 2752
I'm using nop commerce.
I add a new service class to Catalog Controller.
Then it is getting this error.
No parameterless constructor defined for this object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.MissingMethodException: No parameterless constructor defined for this object.
Source Error:
Line 3: @foreach (var widget in Model)
Line 4: {
Line 5: @Html.Action(widget.ActionName, widget.ControllerName, widget.RouteValues)
Line 6: }
Source File: f:\project\sitename\Presentation\Nop.Web\Views\Widget\WidgetsByZone.cshtml Line: 5
I changed this controller.
public CatalogController(ICategoryService categoryService,
IManufacturerService manufacturerService)
to
public CatalogController(ICategoryService categoryService,
IManufacturerService manufacturerService, IbookService bookService)
Then it has getting error.
How to solve it?
Upvotes: 1
Views: 324
Reputation: 2647
This could also happen if you have made changes in ProductService or any of its dependencies that are causing one of them to fail to load. Comment out the parameters in the ProductService constructor and if it works, uncomment each one until you break it again. I don't know of a better way to find out which service is the problem.
Upvotes: 1
Reputation: 1364
If the IProductService you are using here is the original nopCommerce IProductService, I don't find the reason why it would throw the error. But if it's the service you wrote yourself, then you need to register it in DependencyRegistrar.cs. You can look up for current example in nopCommerce on how to register your own dependencies. :)
Upvotes: 3