gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 21:28:18 24 4
gpt4 key购买 nike

我正在使用 nop 商务。

我向目录 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

我改变了这个 Controller 。

public CatalogController(ICategoryService categoryService, 
IManufacturerService manufacturerService)

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

然后就报错了。

如何解决?

最佳答案

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

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com