错误ninject类型" T"必须可以转换为" T"以便将其用作参数" T"在通用方法中

时间:2015-01-04 10:50:18

标签: c# ninject

我有这段代码

public class NinjectControllerFactory : DefaultControllerFactory
{

    private IKernel ninjectKernel;
    public NinjectControllerFactory()
    {
        ninjectKernel = new StandardKernel();
        AddBindings();
    }

    protected override IController GetControllerInstance(
        RequestContext requestContext, Type controllerType)
    {
        return controllerType == null
            ? null
            : (IController)ninjectKernel.Get(controllerType);
    }

    private void AddBindings()
    {
        ninjectKernel
            .Bind<ICollection>().
            To<ListOfProcess.ConnectionLogic.ConnectionLogic>();
    }
}

并在最后一行中出现下一个错误:     类型&#34; T&#34;必须可以转换为&#34; T&#34;以便将其用作参数&#34; T&#34;在通用方法中。

1 个答案:

答案 0 :(得分:1)

好像ListOfProcess.ConnectionLogic.ConnectionLogic没有实现ICollection

(如果它是嵌套类型:不是ListOfProcess,不是ListOfProcess.ConnectionLogic,而ListOfProcess.ConnectionLogic.ConnectionLogic是未实现ICollection