title: Autofac RegisterAssemblyModules throws Autofac.Core.DependencyResolutionException
body: <p>I have a WebAPI 2 that uses Autofac. Below works, but <code>RegisterAssemblyModules</code> throws <code>DependencyResolutionException</code></p>
  
  <pre><code>    builder.RegisterModule&lt;InfrastructureBootstrapper&gt;(); //works
      builder.RegisterModule&lt;LoggingBootstrapper&gt;();
      builder.RegisterModule&lt;AppServicesBootstrapper&gt;();
  </code></pre>
  
  <p><strong>WebAPI 2</strong>    </p>
  
  <pre><code>public static IContainer RegisterTypes()
      {
          var builder = new ContainerBuilder();
  
          //throws DependencyResolutionException
          builder.RegisterAssemblyModules(AppDomain.CurrentDomain.GetAssemblies());
  
          //Below works
          //builder.RegisterModule&lt;InfrastructureBootstrapper&gt;();   
          //builder.RegisterModule&lt;LoggingBootstrapper&gt;();
          //builder.RegisterModule&lt;AppServicesBootstrapper&gt;();
          ...
          builder.RegisterApiControllers(Assembly.GetExecutingAssembly()).InstancePerRequest();
  
          var container = builder.Build();
          container.Resolve&lt;HttpConfiguration&gt;().DependencyResolver = new AutofacWebApiDependencyResolver(container);
  
          return container;
      }
  </code></pre>
  
  <p><strong>InfrastructureBootstrapper</strong>      </p>
  
  <pre><code>public class InfrastructureBootstrapper: Module
      {
          protected override void Load(ContainerBuilder builder)
          {
              base.Load(builder);
              builder.RegisterType&lt;Config&gt;().As&lt;IConfig&gt;();
          }
      }
  </code></pre>
  
  <p><strong>Updated below:</strong><br>
    <strong>LoggingBootstrapper</strong></p>
  
  <pre><code>  public class LoggingBootstrapper: Module
      {
          protected override void Load(ContainerBuilder builder)
          {
              base.Load(builder);
  
              builder.Register(x =&gt; NLog.LogManager.GetCurrentClassLogger()).As&lt;IFileLogger&gt;().SingleInstance();
              builder.RegisterType&lt;Logger&gt;().As&lt;ILogger&gt;();
  
          }
      }
  </code></pre>
  
  <p>All projects use below. </p>
  
  <pre><code> &lt;package id="Autofac" version="4.6.2" targetFramework="net452" /&gt;
  </code></pre>
  
  <p>Info:
  .net 4.5.2, WebAPI 2, Owin hosting, and Windows Service via Topshelf.</p>
  
  <p>The customer api controller uses contractor dependency injection. The injection has not resolved the dependency, thus the exception below:</p>
  
  <pre><code>   Unhandled Exception: Autofac.Core.DependencyResolutionException: An error occurr
      ed during the activation of a particular registration. See the inner exception f
      or details. Registration: Activator = Service (ReflectionActivator), Services =
      [Game.MPC2.RXS.Api.HostServices.IService], Lifetime = Autofac.Core.
      Lifetime.RootScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope -
      --&gt; None of the constructors found with 'Autofac.Core.Activators.Reflection.Defa
      ultConstructorFinder' on type 'Game.MPC2.RXS.Api.HostServices.Servi
      ce' can be invoked with the available services and parameters:
      Cannot resolve parameter 'Game.MPC2.RXS.Logging.ILogger logger' of
      constructor 'Void .ctor(Game.MPC2.RXS.Logging.ILogger, Game.MP
      C2.RXS.Api.HostServices.IWebServer)'. (See inner exception for details.)
       ---&gt; Autofac.Core.DependencyResolutionException: None of the constructors found
       with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Roy
      alMail.MPC2.RXS.Api.HostServices.Service' can be invoked with the availa
      ble services and parameters:
      Cannot resolve parameter 'Game.MPC2.RXS.Logging.ILogger logger' of
      constructor 'Void .ctor(Game.MPC2.RXS.Logging.ILogger, Game.MP
      C2.RXS.Api.HostServices.IWebServer)'.
         at Autofac.Core.Activators.Reflection.ReflectionActivator.GetValidConstructor
      Bindings(IComponentContext context, IEnumerable`1 parameters)
         at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IC
      omponentContext context, IEnumerable`1 parameters)
         at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
         --- End of inner exception stack trace ---
         at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
         at Autofac.Core.Resolving.InstanceLookup.&lt;Execute&gt;b__5_0()
         at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 cr
      eator)
         at Autofac.Core.Resolving.InstanceLookup.Execute()
         at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifeti
      meScope currentOperationScope, IComponentRegistration registration, IEnumerable`
      1 parameters)
         at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration reg
      istration, IEnumerable`1 parameters)
         at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistratio
      n registration, IEnumerable`1 parameters)
         at Autofac.Core.Container.ResolveComponent(IComponentRegistration registratio
      n, IEnumerable`1 parameters)
         at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context,
      Service service, IEnumerable`1 parameters, Object&amp; instance)
         at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Ser
      vice service, IEnumerable`1 parameters)
         at Autofac.ResolutionExtensions.Resolve[TService](IComponentContext context,
      IEnumerable`1 parameters)
         at Autofac.ResolutionExtensions.Resolve[TService](IComponentContext context)
         at Game.MPC2.RXS.Host.Program.Main(String[] args) in C:\_Code\Ro
      yalMail.MPC2.RedX.Service\src\Game.MPC2.RXS.Host\Program.cs:line 17
  </code></pre>