Ninject 2 缺少 RegisterAllControllersln?

发布于 2024-09-10 05:42:35 字数 934 浏览 5 评论 0原文

我完全是 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 4MVC2、Ninject 2.0.0.0 / 2.0.1.0Ninject 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦断已成空 2024-09-17 05:42:36

根据 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

你好,陌生人 2024-09-17 05:42:36

RegisterAllControllersIn 位于 Ninject.Web.MvcNinjectHttpApplication

您可能没有从 MvcApplication [而不是 HttpApplication< 派生 MVC 应用程序/全局类/code> 或类似]。

搜索此类内容的最佳方法是将 MVC、Ninject 和 Ninject.MVC 粘贴到 Reflector 中并执行 F3 搜索

RegisterAllControllersIn lives in Ninject.Web.MvcNinjectHttpApplication

You probably are not deriving your MVC application / global class from MvcApplication [instead of HttpApplication or similar].

Best way of searching stuff like this is to stick MVC, Ninject and Ninject.MVC into Reflector and do an F3-search

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文