0

Im using SimpleInjector in my MVC application. The application is using Identity for Authentication. Im getting an error when I navigate to controllers that use AuthenticationManager in the controller.

The constructor of type ApplicationSignInManager contains the parameter with name 'authenticationManager' and type IAuthenticationManager that is not registered. Please ensure IAuthenticationManager is registered, or change the constructor of ApplicationSignInManager.

Here is what example of what my CompositionRoot looks like.

private static Container RegisterDependencyContainer()
    {
        var container = new Container();

       container.Register<IUserStore<ApplicationUser>>(
         () => new UserStore<ApplicationUser>(), Lifestyle.Singleton);


        // container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
        // container.Register<IUserStore<ApplicationUser>>(
        // () => new SignIn<ApplicationUser>(), Lifestyle.Singleton);

        // Repositories
        var repositoryAssembly = typeof(BootstrapRepository).Assembly;
        var repositoryRegistrations = repositoryAssembly
            .GetExportedTypes()
            .Where(type => type.Namespace == RepositoryNamespace && type.GetInterfaces().Any())
            .Select(type => new
            {
                Interface = type.GetInterfaces().Single(),
                Implementation = type
            });
        foreach (var reg in repositoryRegistrations)
        {
            container.Register(reg.Interface, reg.Implementation, Lifestyle.Transient);
        }

How do I register IAuthenticationManager with SimpleInjector?

scouty
  • 145
  • 1
  • 10
  • What's stopping you from registering `IAuthenticationManager` as the exception message explains? – Steven Jul 18 '18 at 21:28
  • AuthenticationManager doesn't have a constructor from what I see. Also, I don't have access to the HttpContext to get the OwinContext. I guess a better way to word this question is how do I register IAuthenticationManager with SimpleInjector. – scouty Jul 19 '18 at 01:34
  • In that case this is a duplicate, see this answer https://stackoverflow.com/a/28948205/3294832 – Ric .Net Jul 20 '18 at 06:14
  • Hi Scouty, in case you think your question is not a duplicate of Ric's provided answer, and it doesn't solve your problem, please provide additional details so it becomes clear why this doesn't work for you. Please update your question with the appropriate details. – Steven Jul 20 '18 at 11:10

0 Answers0