Castle windsor instances are registered as singleton even though explicitly declare per web request

孤者浪人 提交于 2019-12-24 15:43:14

问题


I am explicitly declaring my registerations as per web request lifecycle but they are still singletons.

this is a problem because my command handlers depend on an IDbConnection which is also registered per web request.

here is my registration code:

container.Register(
    Classes
        .FromAssemblyContaining<EcruiterCommands>()
        .BasedOn(typeof (ICommandHandler<>))
        .WithService.AllInterfaces()
        .LifestylePerWebRequest());

回答1:


I found the issue, the culprit is this line:

.BasedOn(typeof (ICommandHandler<>))

it resets the registration.



来源:https://stackoverflow.com/questions/29627510/castle-windsor-instances-are-registered-as-singleton-even-though-explicitly-decl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!