问题
I am implementing hangFire which is a job scheduling library in my project.
I am facing the same issue as faced in this link
However after replacing LifestylePerWebRequest()
with HybridPerWebRequestTransient()
I am still getting the same error message:
HttpContext.Current is null. PerWebRequestLifestyle can only be used in ASP.Net
Here's a couple of the lines of my dependency installer:
container.Register(Component.For<IApiHra>()
.ImplementedBy(typeof(ApiHra))
.LifeStyle.HybridPerWebRequestTransient()
.IsFallback());
container.Register(Component.For<IApiHraComment>()
.ImplementedBy(typeof(ApiHraComment))
.LifestylePerWebRequest()
.IsFallback());
This is controller installer in windsor controller factory
public class ControllersInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Register(Classes.FromThisAssembly()
.BasedOn<IController>()
.LifestyleTransient());
}
}
Please let me know if any other information is required.
回答1:
See Krzysztof Kozmic's answer here. Your IApiHra
component likely has a PerWebRequestLifestyle
dependency.
来源:https://stackoverflow.com/questions/29913941/castle-windsor-lifestyle-issue