Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ninject 2 missing RegisterAllControllersln?

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

like image 756
Kevin Avatar asked Jul 16 '10 19:07

Kevin


2 Answers

Based on the README for ninject.web.mvc it appears that the line

RegisterAllControllersIn(..)

is only needed for ASP.NET MVC 1

like image 112
jdiaz Avatar answered Nov 09 '22 02:11

jdiaz


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

like image 38
Ruben Bartelink Avatar answered Nov 09 '22 01:11

Ruben Bartelink