我想将IOrchardServices
注入Handler
因为我需要处理程序中的一些服务,所以在我的处理程序中我写了这个:
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.
出了什么问题?
答案 0 :(得分:3)
我无法确定,因为你没有发布所有代码,但听起来你的处理程序上有两个构造函数 - 一个采用IOrchardServices而另一个采用不同的依赖。将构造函数合并到一个方法中,采用两个依赖项:
public class EstatePartHandler : ContentHandler
{
private readonly IOrchardServices Services;
public EstatePartHandler(IOrchardServices services, IAnotherDependency another)
{
Services = services;
Another = another;
}
...
}
如果不是这种情况,请发布处理程序的完整代码。