我的 Ninject.MVC RegisterServices 中有以下行:
kernel.Load(new NinjectBllModule());
kernel.Bind<IMembershipLogicFactory>().ToFactory();
在我的模块里面:
Bind<IUserLogic<LoginUser>>().To<UserLogic>();
Bind<IRoleLogic<SimpleRole, LoginUser>>().To<RoleLogic>();
和我的 IMembershipLogicFactory:
public interface IMembershipLogicFactory
{
IUserLogic<TUser> GetUserLogic<TUser>() where TUser : UserBase;
IRoleLogic<TRole, TUser> GetRoleLogic<TRole, TUser>() where TRole : RoleBase<TUser> where TUser : UserBase<TRole>;
}
然而,当我注入一个 IMembershipLogicFactory 并在其上调用 GetUserLogic() 时,我收到以下错误:
Error activating IUserLogic{LoginUser}
No matching bindings are available, and the type is not self-bindable.
Activation path:
1) Request for IUserLogic{LoginUser}
而且我似乎找不到我做错了什么。