I am using Castle Windsor in MVC application and i have got this problem:
I have IUnitOfWorkProvider
dependency which I want to have PerWebRequest
lifestyle.
In Controller I have these two dependecies:
public class UserController : Controller
{
public UserController(IUnitOfWorkProvider unitOfWorkProvider,
IAuthenticationProvider authenticationProvider)
{
this.unitOfWorkProvider = unitOfWorkProvider;
this.authenticationProvider = authenticationProvider;
}
...
}
AuthenticationProvider
has the same dependency (IUnitOfWorkProvider
)
public class AuthenticationProvider : IAuthenticationProvider
{
public AuthenticationProvider(IUnitOfWorkProvider unitOfWorkProvider)
{
this.unitOfWorkProvider = unitOfWorkProvider;
}
...
}
The problem is that the "two" UnitOfWorkProvider
s (in the controller and in AuthenticationProvider
) are not the same which I would expect them to be.
IAuthenticationProvider
,AuthenticationProvider
and its registration are in different project (Windows Library).
container.Register(Component.For<IUnitOfWorkProvider>()
.ImplementedBy<UnitOfWorkProvider>()
.LifestylePerWebRequest());
LifestylePerThread
does not work with the same error.
When I set LifestyleSignleton
it works fine.
Can anybody help? Thanks.