title: Register generic types in SimpleInjector Version 3
body: <p>I've been following the very helpful answer <a href="https://stackoverflow.com/questions/16064902/dependency-injection-in-unit-of-work-pattern-using-repositories/16085891#16085891">here</a> to organise my unit of work and repositories dynamically using SimpleInjector DI.</p>
  <p>Using the test service below:</p>
  <pre><code>public class TestService
  {
      public TestService(IRepository&lt;Call&gt; calls){}       
  }
  </code></pre>
  <p>In the controller:</p>
  <pre><code>public class TestingController : Controller
  {
  
      private readonly IUnitOfWork _unitOfWork ;
  
      public TestingController(IUnitOfWork unitOfWork, TestService testService)
      {
          _unitOfWork = unitOfWork;
      }
  }
  </code></pre>
  <p>And the bootstrapper:</p>
  <pre><code>public static class BootStrapper
  {
      public static void ConfigureWeb(Container container)
      {
          container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();
                      container.Options.ConstructorResolutionBehavior = new GreediestConstructorBehavior();
  
  
          container.Register&lt;DbContext, OCISContext&gt;(Lifestyle.Scoped);
          container.Register&lt;ApplicationUserManager&gt;(Lifestyle.Scoped);
          container.Register&lt;ApplicationSignInManager&gt;(Lifestyle.Scoped);
          container.Register&lt;IAuthenticationManager&gt;(() =&gt;
              AdvancedExtensions.IsVerifying(container)
                  ? new OwinContext(new Dictionary&lt;string, object&gt;()).Authentication
                  : HttpContext.Current.GetOwinContext().Authentication, Lifestyle.Scoped);
  
          container.Register&lt;IUserStore&lt;ApplicationUser&gt;, UserStore&lt;ApplicationUser&gt;&gt;(Lifestyle.Scoped);
  
          container.Register&lt;IUnitOfWork, UnitOfWork.UnitOfWork&gt;(Lifestyle.Scoped);
          container.RegisterCollection(typeof(IRepository&lt;&gt;), typeof(IRepository&lt;&gt;).Assembly);
          container.Register&lt;TestService&gt;(Lifestyle.Scoped);
      }
  </code></pre>
  <p>I get the error:</p>
  <blockquote>
  <p>An exception of type 'System.InvalidOperationException' occurred in SimpleInjector.dll but was not handled in user code</p>
  <p>Additional information: The configuration is invalid. Creating the instance for type TestService failed. The constructor of type TestService contains the parameter with name 'calls' and type <code>IRepository&lt;Call&gt;</code> that is not registered. Please ensure <code>IRepository&lt;Call&gt;</code> is registered, or change the constructor of TestService. There is, however, a registration for <code>IEnumerable&lt;IRepository&lt;Call&gt;&gt;</code>; Did you mean to depend on <code>IEnumerable&lt;IRepository&lt;Call&gt;&gt;</code>?</p>
  </blockquote>
  <p>I've also, tried</p>
  <pre><code>container.RegisterCollection&lt;IRepository&gt;(new [] {typeof(IRepository)});
  container.RegisterCollection(typeof(IRepository), new[] {typeof(IRepository)});
  </code></pre>
  <p>My intention is to get an instance of GenericRepository as this implents IRepository as shown in the answer in the link above.</p>