Best place to init / dispose WindsorContainer in global.asax?

483 views
Skip to first unread message

Scott_M

unread,
Jun 15, 2012, 10:26:51 AM6/15/12
to castle-pro...@googlegroups.com
We are currently using windsor in our MVC 3 web app.  We currently initialize the WindsorContainer via a static constructor in global.asax to resolve global Logging components and Windows Identity Foundation components.  This seems to work well but I realized that we never dispose of the container.  This seems like a possible anti pattern.  What are the best places to instantiate / dispose the Windsor container in global.asax?

thanks

Mauricio Scheffer

unread,
Jun 15, 2012, 10:45:50 AM6/15/12
to castle-pro...@googlegroups.com
Application_Start and Application_End respectively. See  http://docs.castleproject.org/Windsor.Windsor-tutorial-part-four-putting-it-all-together.ashx  for reference.

Cheers,
Mauricio


On Fri, Jun 15, 2012 at 11:26 AM, Scott_M <scott.kenda...@gmail.com> wrote:
We are currently using windsor in our MVC 3 web app.  We currently initialize the WindsorContainer via a static constructor in global.asax to resolve global Logging components and Windows Identity Foundation components.  This seems to work well but I realized that we never dispose of the container.  This seems like a possible anti pattern.  What are the best places to instantiate / dispose the Windsor container in global.asax?

thanks

--
You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/castle-project-users/-/bT9zo6puEiYJ.
To post to this group, send email to castle-pro...@googlegroups.com.
To unsubscribe from this group, send email to castle-project-u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.

Scott McFadden

unread,
Jun 15, 2012, 3:09:48 PM6/15/12
to castle-pro...@googlegroups.com
I noticed in the windsor tutorial that Application_Start is an instance method that is setting static IWindsorContainer container. I typically see static methods initializing static variables. Is it safe for an instance method (Application_Start) to initialize a static variable (IWindsorContainer container)?

Thanks for the help Mauricio.  

Mauricio Scheffer

unread,
Jun 15, 2012, 3:14:54 PM6/15/12
to castle-pro...@googlegroups.com
Yes, it's safe. See  http://stackoverflow.com/questions/2776233/does-application-start-block-all-incoming-requests  for further explanation and reference.

--
Mauricio
Reply all
Reply to author
Forward
0 new messages