tags:

views:

137

answers:

2

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 (which I downloaded from here github.com/ninject/ninject/downloads) and Ninject Web.mvc extension which i download the source code from github.com/ninject/ninject.web.mvc.

Am I missing something? Please help..

+1  A: 

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

Ruben Bartelink
+2  A: 

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

RegisterAllControllersIn(..)

is only needed for ASP.NET MVC 1

jdiaz