2014-09-04 81 views
1

我正在使用nop商务。为此对象定义的无参数构造函数-nop commerce 2.6

我向Catalog Controller添加一个新的服务类。

然后它得到这个错误。

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) 

,它已收到错误。

如何解决?

+2

这看起来就像您未注册IProductService接口时会遇到的那种错误。你是否正确地注册了你的类型? – Carth 2014-09-04 02:58:42

回答

3

如果你在这里使用的IProductService是原始的nopCommerce IProductService,我没有找到它会抛出错误的原因。但是,如果它是您自己写的服务,那么您需要在DependencyRegistrar.cs中注册它。您可以在nopCommerce中查找当前的示例,了解如何注册您自己的依赖关系。 :)

1

如果您在ProductService或其任何导致其中一个无法加载的相关性中进行了更改,也会发生这种情况。注释掉ProductService构造函数中的参数,如果它有效,则取消每个参数的注释,直到再次分解为止。我不知道有更好的方法来找出哪个服务是问题。

相关问题