我有一些知识库。与他们一起工作是通过接口IRepository
实现的。
在sample projectHomeController
用ISession实现的构造函数。当我写这个:IRepository vs ISession
public class TestingController : Controller
{
private ISession session;
public TestingController(ISession session)
{
this.session = session;
}
//Some code here with this.session
}
它运作良好。当我决定使用IRepository
:
public class TestingController : Controller
{
private IRepository repository;
public TestingController(IRepository repository)
{
this.repository = repository;
}
//Some code here with this.repository
}
它不会在其他类WindsorControllerFactory
的这种方法工作:
protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType)
{
if (controllerType == null)
{
throw new HttpException(404, string.Format("The controller for path {0} culd not found!", requestContext.HttpContext.Request.Path));
}
return (IController)this.kernel.Resolve(controllerType);
}
我有例外
无法创建组件“MvcApplication1 .Controllers.ResultsController',因为它具有依赖性。
'MvcApplication1.Controllers.ResultsController'正在等待下列依赖项的 : - Service'dal.Repository.IRepository'未注册。
如何解决?
P.S.装配dal.Repository
正在工作。如果我写new dal.Repository.Repository()
而不是this.repository
- 它正在工作。
IT WORKS !!!))) 非常感谢你)对我来说很难 - 理解这一点) – LuckSound 2012-04-18 10:10:22