The question of the style of Windsor Castle

I am using hangFire which is a task scheduling library in my project.

I faced the same problem as in this link

However, after replacing LifestylePerWebRequest()

with, HybridPerWebRequestTransient()

I still get the same error message:

HttpContext.Current is null. PerWebRequestLifestyle can only be used in ASP.Net

Here are some 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 the controller installer in the 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 needed.

+3


source to share


1 answer


See Krzysztof Kozmic's answer here . Your component IApiHra

most likely has a dependency PerWebRequestLifestyle

.



0


source







All Articles