与Ninject帮助MVC3! [英] Help with Ninject in mvc3!
本文介绍了与Ninject帮助MVC3!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的继承人问题。
我的应用程序有几个项目。
Heres my problem. My app has several projects.
- WEB(控制器和视图)
- 服务
- 数据(EDMX和库)
- 实体(POCO)
- 测试
所以在我的Web项目我有ninject配置
So in my Web project I have the ninject configuration
[assembly: WebActivator.PreApplicationStartMethod(typeof(PublicPanama.AppStart_NinjectMVC3), "Start")]
namespace Web{
public static class AppStart_NinjectMVC3 {
public static void RegisterServices(IKernel kernel) {
//kernel.Bind<IThingRepository>().To<SqlThingRepository>();
kernel.Bind<IContributorService>().To<ContributorService>();
}
public static void Start() {
// Create Ninject DI Kernel
IKernel kernel = new StandardKernel();
// Register services with our Ninject DI Container
RegisterServices(kernel);
// Tell ASP.NET MVC 3 to use our Ninject DI Container
DependencyResolver.SetResolver(new NinjectServiceLocator(kernel));
}
}
}
问题是,我也想补充
The problem is, I also want to add
kernel.Bind<IRepository>().To<Repository>();
但我的Web项目不具备数据项目的引用..和刚刚加入的,这并不参考似乎是正确..
But my Web project does not have a reference to the Data project.. and just adding the reference for this doesnt seem right..
我缺少什么?
请大家帮忙!
what am I missing? please help!
推荐答案
的http://www.planetgeek.ch/2010/11/13/official-ninject-mvc-extension-gets-support-for-mvc3/
和不要忘记阅读@Brad Wilson的博客系列(ref'd条)
And dont forget to read @Brad Wilson's blog series (ref'd in article)
这篇关于与Ninject帮助MVC3!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文