title: Struggling with exemption 'Unity.Exceptions.InvalidRegistrationException'
body: <p>I installed Unity and followed this guys example to implement dependency injection into my mvc application,<a href="https://medium.com/aeturnuminc/repository-pattern-with-dependency-injection-mvc-ef-code-first-91344413ba1c" rel="nofollow noreferrer">Link</a> now when i run my project i am faced with the following exemptions.</p>
  
  <p>System.InvalidOperationException: 'An error occurred when trying to create a controller of 
  type 'SaaS.Controllers.AccountController'. Make sure that the controller has a parameterless
   public constructor</p>
  
  <p>InvalidRegistrationException: Exception of type 
  'Unity.Exceptions.InvalidRegistrationException' was thrown.</p>
  
  <pre><code> [Authorize]
  public class AccountController : Controller
  {
      private ApplicationSignInManager _signInManager;
      private ApplicationUserManager _userManager;
      private ITenantRepository TenantRepo;
      private ISetupRepository SetupRepo;
      private IAppUserRepository AppUserRepo;
      private IEmployeeRepository EmployeeRepo;
  
      public AccountController()
      {
  
      }
  
      public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager, ITenantRepository TenantRepo,
          ISetupRepository SetupRepo, IAppUserRepository AppUserRepo, IEmployeeRepository EmployeeRepo)
      {
          UserManager = userManager;
          SignInManager = signInManager;
          this.TenantRepo = TenantRepo;
          this.SetupRepo = SetupRepo;
          this.AppUserRepo = AppUserRepo;
          this.EmployeeRepo = EmployeeRepo;
      }
  </code></pre>
  
  <p>one of the repoitories </p>
  
  <pre><code>    public static void RegisterComponents()
          {
          var container = new UnityContainer();
  
          container.RegisterType&lt;ISetupRepository, SetupRepository&gt;();
          container.RegisterType&lt;ITenantRepository, TenantRepository&gt;();
          container.RegisterType&lt;ISetupLocationRepository, SetupLocationRepository&gt;();
          container.RegisterType&lt;ISetupCalendarOfficeRepository, SetupCalendarOfficeRepository&gt;();
          container.RegisterType&lt;IAppUserRepository, AppUserRepository&gt;();
          container.RegisterType&lt;ICacheService, InMemoryCache&gt;();
  
          container.RegisterType&lt;IEmpPersonalDetailRepository, EmpPersonalDetailRepository&gt;();
          container.RegisterType&lt;IEmpSportRepository, EmpSportRepository&gt;();
          container.RegisterType&lt;IEmployeeRepository, EmployeeRepository&gt;();
  
          container.RegisterType&lt;IEmpContactDetailRepository, EmpContactDetailRepository&gt;();
  
          container.RegisterType&lt;IEmpEmploymentDetailRepository, EmpEmploymentDetailRepository&gt;();
          container.RegisterType&lt;IEmpVacationEntitlementRepository, EmpVacationEntitlementRepository&gt;();
          container.RegisterType&lt;IEmpCalendarRepository, EmpCalendarRepository&gt;();
  
          container.RegisterType&lt;IEmpSalaryRepository, EmpSalaryRepository&gt;();
          container.RegisterType&lt;ISetupSalaryComponantRepository, SetupSalaryComponantRepository&gt;();
          container.RegisterType&lt;ISetupPayGradeRepository, SetupPayGradeRepository&gt;();
          container.RegisterType&lt;IEmpPartSalaryRepository, EmpPartSalaryRepository&gt;();
          container.RegisterType(typeof(IUserStore&lt;ApplicationUser&gt;), typeof(UserStore&lt;ApplicationUser&gt;));
  
  
          DependencyResolver.SetResolver(new UnityDependencyResolver(container));
      }
  
      public class SetupRepository : ISetupRepository/*, IDisposable*/
      {
      [Dependency]
      public DataBaseContext context { get; set; }
  
      public void Add(Setup entity)
      {
              context.Setups.Add(entity);
              context.SaveChanges();
      }
      }
  </code></pre>