title: Register generic Autofac factory
body: <p>I have ICommand and <code>ICommandHandler&lt;TCommand&gt;</code> interfaces and I want to inject to factory. Could you please check and let me know what i do wrong? I do it as below:</p>
  
  <p>CommandBus - here i received error (shown below in blackquote)</p>
  
  <pre><code>var handler = _context.Resolve&lt;ICommandHandler&lt;TCommand&gt;&gt;();
  </code></pre>
  
  <p>I Register my command handler in AutofacModule class</p>
  
  <pre><code>builder.RegisterType&lt;CreateMakeCommandHandler&gt;()
      .As&lt;ICommandHandler&lt;CreateBaseCommand&lt;MakeEntity&gt;&gt;&gt;();
  </code></pre>
  
  <blockquote>
    <p>Autofac.Core.Registration.ComponentNotRegisteredException: The requested service 'Shop.Services.CommandHandlers.BaseCommandHandlers.ICommandHandler'1[[Shop.Domain.Commands.Model.CreateModelCommand' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.
       at Shop.Services.CommandHandlers.BaseCommandHandlers.CommandBus.d__7'1.MoveNext() in C:\Projects\Shop\Shop\Shop\Services\CommandHandlers\BaseCommandHandlers\CommandBus.cs:line 31</p>
  </blockquote>
  
  <p>Thank you in advance.</p>
  
  <p>Edit:</p>
  
  <pre><code>public class CreateBaseCommand&lt;TEntity&gt; : BaseCommand where TEntity : BaseEntity
  {}
  </code></pre>