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

标签 c# asp.net nopcommerce

我正在使用 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/

相关文章:

C# 条件运算符不是语句?

c# - 在SQL Server中的存储过程中进行查询但出现一些错误

c# - 程序如何知道传递了哪些参数?

c# - 使用 vstest.consol.exe 运行 Moq 单元测试

c# - ASP.net 在每次页面加载时抛出错误(Base-64 字符数组的长度无效)

发布 NopCommerce 问题

c# - Ninject 中的泛型和属性绑定(bind)

docker - Dockerize dotnet core 2.2应用程序,在nopCommerce Dockerfile中放置哪些行以及为什么放行?

C#:加载 *.txt 到 RichTextBox 并转换为 UTF8

asp.net - Visual Studio或插件中是否有工具可以自动创建伙伴类验证?