我有这段代码
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;在通用方法中。
答案 0 :(得分:1)
好像ListOfProcess.ConnectionLogic.ConnectionLogic
没有实现ICollection
。
(如果它是嵌套类型:不是ListOfProcess
,不是ListOfProcess.ConnectionLogic
,而ListOfProcess.ConnectionLogic.ConnectionLogic
是未实现ICollection
的