I'm working on an ASP.NET MVC3 application, which has a custom MembershipProvider to handle authentication. This provider has a dependency on a service called IUserService, which is being set by property injection.
public class MyMembershipProvider : MembershipProvider
{
public IUserService UserService { get; set; }
public override bool ValidateUser(string username, string password)
{
return UserService.IsValidLogon(username, password);
}
}
I'm using Castle Windsor 3 to manage everything. In my application startup, I register the membership provider successfully:
protected void Application_Start()
{
_container = new WindsorContainer().Install(FromAssembly.This());
_container.Register(Component.For<MyMembershipProvider>().LifeStyle.Transient.Named("myProvider"));
}
but when the provider gets called, I get a null reference exception for the UserService property. How can I tell Castle Windsor to inject my property?