2014-09-04 3 views
1

저는 상업 거래를 사용하고 있습니다.이 개체에 대해 정의 된 매개 변수없는 생성자가 없습니다.-nop commerce 2.6

카탈로그 컨트롤러에 새 서비스 클래스를 추가합니다.

그런 다음이 오류가 발생합니다.

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

답변

3

IProductService 여기에 원래 nopCommerce IProductService를 사용하고 있는데 오류가 발생하는 이유를 찾지 못했습니다. 그러나 자신이 작성한 서비스 인 경우 DependencyRegistrar.cs에 등록해야합니다. 자신의 의존성을 등록하는 방법에 대한 nopCommerce의 현재 예제를 찾을 수 있습니다. :)

1

ProductService 나 그 중 하나가로드에 실패하는 종속성을 변경 한 경우에도 발생할 수 있습니다. ProductService 생성자의 매개 변수를 주석 처리하고 작동하는 경우 다시 분해 할 때까지 각 매개 변수의 주석 처리를 제거하십시오. 어떤 서비스가 문제인지 더 나은 방법을 알 수는 없습니다.