title: Accessing ninject kernel in Application_Start
body: <p>I am using Ninject and the MVC3 extension installed with nuget. My kernel setup code is in the App_Start/NinjectMVC3.cs file. Everything works great in controllers, but I can't figure out how to (properly) bind interfaces in the Global.asax.cs MvcApplication code. </p>
  
  <p>I ended up using a hack (creating a public NinjectMVC3.GetKernel() method that returns bootstrap.kernel). However, that will be deprecated, and there must be a proper way to do this that I am not seeing.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public class LogFilterAttribute : ActionFilterAttribute
  {
      private IReportingService ReportingService { get; set; }
      public LogFilterAttribute( IReportingService reportingService )
      {
          this.ReportingService  = reportingService;
      }
      ...
  }
  
  public class MvcApplication : System.Web.HttpApplication
  {
      public static void RegisterGlobalFilters( GlobalFilterCollection filters )
      {
          filters.Add( new HandleErrorAttribute() );
          filters.Add( new LogFilterAttribute()  );
      }
      ...
      protected void Application_Start()
      {
          ...
          RegisterGlobalFilters( GlobalFilters.Filters );
          // NOTE hack:
          var kernel = NinjectMVC3.GetKernel();
          var logger = kernel.Get&lt;ILogger&gt;();
          var bw = new BackgroundWork(logger);
          Application["BackgroundWork"] = bw;
          bw.Start();
      }
  }
  </code></pre>
  
  <p>There are two interfaces I am interested in. The first is just binding an object to a Global variable (the ILogger for the BackgroundWork).</p>
  
  <p>And the second is for an ActionFilter. I read <a href="http://www.planetgeek.ch/2010/11/13/official-ninject-mvc-extension-gets-support-for-mvc3/" rel="noreferrer">http://www.planetgeek.ch/2010/11/13/official-ninject-mvc-extension-gets-support-for-mvc3/</a>, but I don't see how it plugs into the actual registration (filter.Add).</p>
  
  <p>I don't want to use the Property Inject if I can avoid it.</p>
  
  <p>Any thoughts on the proper way to do this?
  Thanks </p>