1

我想注入IOrchardServicesHandler因为我需要处理程序中的一些服务,所以在我的处理程序中我写了这个:

public class EstatePartHandler : ContentHandler
{
    private readonly IOrchardServices Services;
    public EstatePartHandler(IOrchardServices services)
    {
        Services = services;
    }
...
}

但是Orchard在构造处理程序时抛出异常:

Cannot choose between multiple constructors with equal length 1 on type 'Estate.Handlers.EstatePartHandler'. Select the constructor explicitly, with the UsingConstructor() configuration method, when the component is registered.

怎么了?

4

1 回答 1

3

我无法确定,因为您尚未发布所有代码,但听起来您的处理程序上有两个构造函数 - 一个采用 IOrchardServices,另一个采用不同的依赖项。将您的构造函数合并到一个方法中,采用两个依赖项:

public class EstatePartHandler : ContentHandler
{
    private readonly IOrchardServices Services;
    public EstatePartHandler(IOrchardServices services, IAnotherDependency another)
    {
        Services = services;
        Another = another;
    }
...
}

如果不是这种情况,请发布您的处理程序的完整代码。

于 2012-08-28T11:29:47.727 回答