没有为此无对象电子商务2

没有为此无对象电子商务2

我正在使用nop Commerce。

我向目录控制器添加一个新的服务类。

然后,它得到这个错误。

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


我改变了这个控制器。

public CatalogController(ICategoryService categoryService,
            IManufacturerService manufacturerService)




public CatalogController(ICategoryService categoryService,
            IManufacturerService manufacturerService, IbookService bookService)


然后它有错误。

怎么解决呢?

最佳答案

如果您在此处使用的IProductService是原始的nopCommerce IProductService,则找不到导致该错误的原因。但是,如果这是您自己编写的服务,则需要在DependencyRegistrar.cs中进行注册。您可以在nopCommerce中查找有关如何注册自己的依赖项的当前示例。 :)

关于c# - 没有为此无对象电子商务2.6定义无参数构造函数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25656590/

10-11 00:59