title: ASP.NET WebApi + Autofac not finding ApiControllers
body: <p>I'm trying to get Autofac to work with WebApi. I have my ApiControllers in a separate project from the main web project. </p>
  
  <p>InventorySystem.Web.UI
  InventorySystem.Web.Api.Controllers</p>
  
  <p>Whenever i try to browse to an api route i get the response:</p>
  
  <pre><code>&lt;Exception xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
      &lt;ExceptionType&gt;System.ArgumentNullException&lt;/ExceptionType&gt;
      &lt;Message&gt;Value cannot be null. Parameter name: value&lt;/Message&gt;
      &lt;StackTrace&gt;
  at System.Web.Http.Controllers.HttpControllerContext.set_Controller(IHttpController value)
  at System.Web.Http.Dispatcher.DefaultHttpControllerFactory.CreateInstance(HttpControllerContext controllerContext, HttpControllerDescriptor controllerDescriptor)
  at System.Web.Http.Dispatcher.DefaultHttpControllerFactory.CreateController(HttpControllerContext controllerContext, String controllerName)
  at Autofac.Integration.WebApi.AutofacControllerFactory.CreateController(HttpControllerContext controllerContext, String controllerName)
  at System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsyncInternal(HttpRequestMessage request, CancellationToken cancellationToken)
  at System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
      &lt;/StackTrace&gt;
  &lt;/Exception&gt;
  </code></pre>
  
  <p>When i step through the Autofac code I see that my controller has been registered, but the AutofacControllerActivator.Create() returns null. Specifically the line
      return (ResolutionExtensions.ResolveOptional(scope, controllerType) as IHttpController);</p>
  
  <p>The autofac code:
  string binDirectory = Path.Combine(HttpRuntime.AppDomainAppPath, "bin");</p>
  
  <pre><code>        var builder = new ContainerBuilder();
  
          builder.ConfigureWebApi(GlobalConfiguration.Configuration);
  
          builder.RegisterControllers(Assembly.GetExecutingAssembly()).PropertiesAutowired();
          builder.RegisterApiControllers(Assembly.LoadFile(Path.Combine(binDirectory, "InventorySystem.Web.Api.dll"))).PropertiesAutowired();
          builder.RegisterFilterProvider();            
  
          var container = builder.Build();
  
          DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
          GlobalConfiguration.Configuration.ServiceResolver.SetResolver(new AutofacWebApiDependencyResolver(container));
  </code></pre>
  
  <p>Am i missing something?</p>
  
  <p>Thanks</p>