私はいくつかのリポジトリを持っています。それらの作業は、インタフェースIRepository
によって実現されます。
sample projectHomeController
コンストラクタがISessionで実現されました。私がこれを書きました:IRepository対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は」 次の依存を待っています: - 登録されていなかったサービス「dal.Repository.IRepository」を。
どのように解決するのですか?
P.S.アセンブリdal.Repository
が動作しています。もし私がどこでも書いたらthis.repository
の代わりにnew dal.Repository.Repository()
- それは働いています。
IT WORKS !!!))) ありがとうございました)私にとっては難しい - これを理解すること) – LuckSound