开发者

Castle windsor - creating and disposing container in WCF services

am planning to implement Castle windsor in WCF layer, which is an ASP.Net project. When I went through the documentation of Castle windsor it was said that we need to create container only once and dispose it after using it. So am struck at this point in my scenario where I need to create container in WCF. I initially thought of putting that on Application_start in global.asax.vb and dispose it in Application_End but application_end will be called when App pool recycles or iis restart etc.

So second thing came to my mind was Session_start and Session_end. Again session end will work for only Inproc type. Also it might get called only after certain amount of idle time.

Third option is to call in each method to create instance and close i开发者_如何学Pythont after each method. which is not advisable from what I know.

So could you please suggest which is the best way for this.

Thanks in advance Sai


You would usually configure your IOC container only once per application lifetime, and doing this in Application_Start() seems perfectly reasonable. Reconfiguring it for each new session or for each request most probably is just doing unnecessary work; also, I suspect this could hurt performance.

I don't see anything wrong with Application_Start() / Application_End() approach. If you fear it may leak resources or something like that, then these fears are unjustified.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜