1

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.

なにが問題ですか?

4

1 に答える 1

3

すべてのコードを投稿していないため、確かなことはわかりませんが、ハンドラーに 2 つのコンストラクターがあるようです。1 つは IOrchardServices を受け取り、もう 1 つは別の依存関係を受け取ります。コンストラクターを 1 つのメソッドにマージし、2 つの依存関係を取ります。

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

そうでない場合は、ハンドラーの完全なコードを投稿してください。

于 2012-08-28T11:29:47.727 に答える