[英]The type 'T' must be a reference type in order to use it as parameter 'T' in the generic type or method 'QueryAPI.Query<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.