title: Dependency injection in WebApiConfig class
body: <p>Can I Inject an instance of a class using Ninject in WebApiConfig class of a Asp.net Web Api project?
  This is my attempt</p>
  
  <pre><code>    public static class WebApiConfig
      {    
          private static IAccountsService _accountsService;
  
          [Inject]
          public static IAccountsService AccountsService 
          {
              get { return _accountsService; }
              set { _accountsService = value; }
          }
  
          public static void Register(HttpConfiguration config)
          {
              var authentication = CreateAuthenticationConfiguration();
              config.MessageHandlers.Add(new AuthenticationHandler(authentication));
  
              config.Routes.MapHttpRoute(
                  name: "DefaultApi",
                  routeTemplate: "api/{controller}/{id}",
                  defaults: new { id = RouteParameter.Optional }
              );
  
              config.EnableSystemDiagnosticsTracing();
          }
  
          private static AuthenticationConfiguration CreateAuthenticationConfiguration()
          {
              var authentication = new AuthenticationConfiguration
              {
                  RequireSsl = false,
                  EnableSessionToken = true
              };
  
              // Basic Authentication
              authentication.AddBasicAuthentication(AccountsService.ValidateAccountUsingSiteCredential);
  
              return authentication;
          }
      }
  </code></pre>
  
  <p>However, I am getting <code>Object reference not set to an instance of an object</code> on this line <code>authentication.AddBasicAuthentication(AccountsService.Validate);</code></p>