Hi I have been trying to register the default IUserStore that is in the premade Identity class ApplicationUserManager with SimpleInjector
public class ApplicationUserManager : UserManager<ApplicationUser, int>
{
public ApplicationUserManager(IUserStore<ApplicationUser, int> store)
: base(store)
{
}
I have a SimpleInjectorInitializer file in the App_Start folder that looks like this:
public static class SimpleInjectorInitializer
{
public static void RegisterDependencies(Container container)
{
container.Register<ICatalogRepository, CatalogRepository>();
container.Register<IUserRepository, UserRepository>();
container.Register<ICatalogService, CatalogService>();
container.Register<IUserService, UserService>();
container.Register<IAdminService, AdminService>();
container.Register<AccountController>();
container.Register<ApplicationUserManager>();
//container.Register<CustomUserStore>();
//container.RegisterCollection(typeof(IUserStore<>), new[] { typeof(ApplicationUser) });
//container.Register<IUserStore<>, store>();
//container.RegisterPerWebRequest<IUserStore<ApplicationUser>>(() => new UserStore<ApplicationUser>(container.GetInstance<ApplicationDbContext>()));
container.Verify();
}
}
As you can see I have tried a few times to get it working by looking at similar Stack Overflow questions but it has either not changed the outcome or given a syntax error.
Currently when clicking the sign in button on the application homepage, this error is thrown:
The constructor of type ApplicationUserManager contains the parameter with name 'store' and type IUserStore that is not registered. Please ensure IUserStore is registered, or change the constructor of ApplicationUserManager.
If the two lines below register ApplicationUserManager are uncommented then this error is thrown:
An exception of type 'System.ArgumentException' occurred in SimpleInjector.dll but was not handled in user code
Additional information: The supplied type ApplicationUser does not implement IUserStore.
Any help on this would be appreciated.