C# 没有为此对象定义无参数构造函数nop commerce 2.6

C# 没有为此对象定义无参数构造函数nop commerce 2.6,c#,asp.net,nopcommerce,C#,Asp.net,Nopcommerce,我用的是nop商务 我向Catalog Controller添加了一个新的服务类 public CatalogController(ICategoryService categoryService, IManufacturerService manufacturerService) 然后它得到了这个错误 No parameterless constructor defined for this object. Description: An unhandled exc

我用的是nop商务

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

public CatalogController(ICategoryService categoryService, 
            IManufacturerService manufacturerService)
然后它得到了这个错误

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)

那么它就有了错误


如何解决它?

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

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

如果您对ProductService或其任何依赖项进行了更改,导致其中一个无法加载,也可能发生这种情况。注释掉ProductService构造函数中的参数,如果它起作用,则取消对每个参数的注释,直到再次打断它。我不知道有什么更好的方法来找出哪个服务是问题所在。

如果您对ProductService或其任何依赖项进行了更改,导致其中一个无法加载,也可能会发生这种情况。注释掉ProductService构造函数中的参数,如果它起作用,则取消对每个参数的注释,直到再次打断它。我不知道有什么更好的方法来找出哪个服务是问题所在。

如果您没有注册IPProductService接口,您可能会遇到这种错误。您是否正确注册了类型?如果没有注册IPProductService接口,您可能会遇到这种错误。您正确注册了您的类型吗?