I setup a CustomRoleProver as:
public class CustomRoleProvider : RoleProvider
{
private readonly IRepository _repository;
pu
You're writing a roleprovider, but these are not currently DI aware. A lot of the classes in MVC are DI aware, which is why you see it workign with controllers.
To be able to inject a constructor parameter the DI container has to be responsible for creating the object you're hoping to inject into. Just registering a type does not magically make it locatable.
With roleproviders, it is the Roles class within the framework that create instances of the providers, including your custom provider. It only works parameterless constructors. You'll need to use something like property injection within your custom provider and use Roles.Provider to get the instance to inject your dependencies into.