簡體   English   中英

錯誤注入類型“ T”必須轉換為“ T”才能在通用方法中將其用作參數“ T”

[英]Error ninject the type “T” must be convertable to “T”in order to use it as a parameter “T” in generic method

我有這個代碼

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>();
    }
}

並在最后一行出現下一個錯誤:類型“ T”必須可轉換為“ T”,以便在通用方法中將其用作參數“ T”。

似乎ListOfProcess.ConnectionLogic.ConnectionLogic沒有實現ICollection

(如果它是嵌套類型:不是ListOfProcess ,不是ListOfProcess.ConnectionLogic但是ListOfProcess.ConnectionLogic.ConnectionLogic是不實現ICollection

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM