title: Ninject and asp.net MVC4
body: <p>I have a MVC3 application that I would like to port to MVC4. I am using Ninject for dependency injection. Using Nuget, I added "Ninject" to my project and created a controller factory as shown below</p>
  
  <pre><code>public class NinjectControllerFactory : DefaultControllerFactory
  {
      private IKernel ninjectKernel;
  
      public NinjectControllerFactory()
      {
          ninjectKernel = new StandardKernel();
          AddBindings();
      }
  
      protected override IController GetControllerInstance(RequestContext  requestContext, Type controllerType)
      {
          return controllerType == null ? null : (IController)ninjectKernel.Get(controllerType);
      }
  
      private void AddBindings()
      {
          //Add ninject bindings here
      }
  }
  </code></pre>
  
  <p>This works fine for MVC3 but things have changed in MVC4. I did some digging and found this link that explains how to get ninject working for MVC4</p>
  
  <p><a href="http://haacked.com/archive/2012/03/11/itrsquos-the-little-things-about-asp-net-mvc-4.aspx" rel="noreferrer">http://haacked.com/archive/2012/03/11/itrsquos-the-little-things-about-asp-net-mvc-4.aspx</a></p>
  
  <p>However, I am having trouble getting the code in the above link to compile. Specifically, The code that I am supposed to place in the Start() method of the web.common file gives me unresolved namespace errors</p>
  
  <pre><code>GlobalConfiguration.Configuration.ServiceResolver
    .SetResolver(DependencyResolver.Current.ToServiceResolver());
  </code></pre>
  
  <p>Both "ServiceResolver" and ".SetResolver" are unresolved. What references do I need to add to enable these? Also, if possible can you point me towards a tutorial showing me how to get ninject working in MVC4 without having to install the nuget package ninject.mvc3? I ask because I would prefer not to have any packages installed in my application that were written for MVC3 specifically to avoid things from breaking down the line if these nuget packages are updated.</p>
  
  <p>edit: I should have added that I am using Visual studio 2012 and .Net 4.5</p>