Ninject 2 缺少 RegisterAllControllersln?
我完全是 Ninject
的新手,我尝试遵循 Shiju Varghese 的教程 他关于 DI 的博客文章。
我确实添加了 ninject.dll 和 Ninject.Web.Mvc.dll 的引用 但是,我陷入困境,因为 Visual Studio 无法解析函数 RegisterAllControllersIn...
protected override void OnApplicationStarted()
{
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
// RegisterAllControllersIn could not be found!!
RegisterAllControllersIn(Assembly.GetExecutingAssembly());
}
我正在使用 Visual Studio 2010 Prof
、.Net 4
、MVC2、Ninject 2.0.0.0 / 2.0.1.0 和 Ninject Web.mvc 扩展
I'm totally a newbie with Ninject
and I tried to follow the tutorial by Shiju Varghese at his blog post about DI.
I did add reference of ninject.dll and Ninject.Web.Mvc.dll
However, I got stuck as Visual Studio cannot resolve the function RegisterAllControllersIn....
protected override void OnApplicationStarted()
{
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
// RegisterAllControllersIn could not be found!!
RegisterAllControllersIn(Assembly.GetExecutingAssembly());
}
I'm using Visual Studio 2010 Prof
, .Net 4
, MVC2
, Ninject 2.0.0.0 / 2.0.1.0 and Ninject Web.mvc extension
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据 ninject.web.mvc 的自述文件 看来,RegisterAllControllersIn
(. .)
仅 ASP.NET MVC 1 需要
Based on the README for ninject.web.mvc it appears that the line
RegisterAllControllersIn(..)
is only needed for ASP.NET MVC 1
RegisterAllControllersIn
位于Ninject.Web.MvcNinjectHttpApplication
您可能没有从
MvcApplication
[而不是HttpApplication< 派生 MVC 应用程序/全局类/code> 或类似]。
搜索此类内容的最佳方法是将 MVC、Ninject 和 Ninject.MVC 粘贴到 Reflector 中并执行 F3 搜索
RegisterAllControllersIn
lives inNinject.Web.MvcNinjectHttpApplication
You probably are not deriving your MVC application / global class from
MvcApplication
[instead ofHttpApplication
or similar].Best way of searching stuff like this is to stick MVC, Ninject and Ninject.MVC into Reflector and do an F3-search