title: No registration for type ICommandHandler using SimpleInjector APIv3
body: <p>I've been playing around with SimpleInjector and I'm trying to register properly all command handlers.</p>
  
  <p>Here is my code:</p>
  
  <h2>CQRS.cs</h2>
  
  <pre><code>public interface ICommand {}
  
  public interface ICommandDispatcher
  {
      void Execute(ICommand command);
  }
  
  public class CommandDispatcher : ICommandDispatcher
  {
      private readonly Container container;
  
      public CommandDispatcher(Container container)
      {
          this.container = container;
      }
  
      public void Execute(ICommand command)
      {
          var handlerType = typeof(ICommandHandler&lt;&gt;).MakeGenericType(command.GetType());
  
          dynamic handler = container.GetInstance(handlerType);
  
          handler.Handle((dynamic)command);
      }
  }
  
  public interface ICommandHandler&lt;in TParameter&gt; where TParameter : ICommand
  {
      void Handle(TParameter command);
  }
  </code></pre>
  
  <h2>Handler.cs</h2>
  
  <pre><code>public class UserCommandsHandler : ICommandHandler&lt;CreateUser&gt;
  {
      public void Handle(CreateUser message)
      {
          var user = new User(message.Email);
          /* logic here */
      }
  }
  </code></pre>
  
  <h2>Command.cs</h2>
  
  <pre><code>public class CreateUser : ICommand
  {
      public readonly string Email;
  
      public CreateUser(string email)
      {
          Email = email;
      }       
  }
  </code></pre>
  
  <h2>Global.asax.cs</h2>
  
  <pre><code>var assemblies = new[] { typeof(ICommandHandler&lt;&gt;).Assembly };
  var container = new SimpleInjector.Container();
  container.RegisterCollection(typeof(ICommandHandler&lt;&gt;), assemblies);
  container.RegisterSingleton&lt;ICommandDispatcher&gt;(new CommandDispatcher(container));
  container.Verify();
  DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
  </code></pre>
  
  <h2>HomeController.cs</h2>
  
  <pre><code>public class HomeController : Controller
  {
      private readonly ICommandDispatcher _commandDispatcher;
  
      public HomeController(ICommandDispatcher commandDispatcher)
      {
          _commandDispatcher = commandDispatcher;
      }
  
      public ActionResult Index()
      {
          var command = new CreateUser("email@example.com");
          _commandDispatcher.Execute(command);
          return Content("It works");
      }
  }
  </code></pre>
  
  <p>at CQRS.cs</p>
  
  <pre><code>dynamic handler = container.GetInstance(handlerType);
  </code></pre>
  
  <p>I get:</p>
  
  <blockquote>
    <p>No registration for type <code>ICommandHandler&lt;CreateUser&gt;</code> could be found. 
        There is, however, a registration for <code>IEnumerable&lt;ICommandHandler&lt;CreateUser&gt;&gt;</code>;
        Did you mean to call <code>GetAllInstances&lt;ICommandHandler&lt;CreateUser&gt;&gt;()</code> or depend on <code>IEnumerable&lt;ICommandHandler&lt;CreateUser&gt;&gt;</code>?</p>
  </blockquote>