title: An error occurred during the activation of a particular registration while using Autofac
body: <p>This is the way we register the classes using <code>Autofac</code></p>
  
  <pre><code>builder.Register(c =&gt; new FileLogger(ILogger)).As&lt;ILogger&gt;().SingleInstance();
  
  var sizeinkb= Convert.ToInt32(configuration.GetValue&lt;string&gt;("Settings:SizeInKb"));
  
  builder.RegisterType&lt;Broker&gt;().As&lt;IBroker&gt;().WithParameter("size", sizeinkb).SingleInstance();
  builder.RegisterType&lt;MainClass&gt;().As&lt;IMainClass&gt;().SingleInstance();
  
  var container = builder.Build();
  ContainerFactory.SetContainer(container);
  </code></pre>
  
  <p>Here is our class</p>
  
  <pre><code>public class MainClass:IMainClass
  {
      public MainClass(IBroker broker,ILogger logger)
      {
          _broker = broker,
          _logger = logger
      }
  }
  </code></pre>
  
  <p>Here is the broker class</p>
  
  <pre><code>public class Broker:IBroker 
  {
       public Broker(ILogger logger,
               int size)
       {
  
       }
  }
  </code></pre>
  
  <blockquote>
    <p>Autofac.Core.DependencyResolutionException
      HResult=0x80131500
      Message=An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = MainClass (ReflectionActivator), Services = [MyProject.IMainClass], Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'MyProject.MainClass' can be invoked with the available services and parameters:
    Cannot resolve parameter 'MyProject.IBroker  broker' of constructor 'Void .ctor(MyProject.IBroker, MyProject.ILogger)'.</p>
  </blockquote>