title: How should I implement an MVC Bootstrapper for Unity and AutoMapper?
body: <p>What is the best way to create a bootstrapper for my MVC 2 app?  I'm using Unity and AutoMapper and want to abstract the loading and configuration of them as much as possible.</p>
  
  <p>A decent example is here (<a href="http://weblogs.asp.net/rashid/archive/2009/02/17/use-bootstrapper-in-your-asp-net-mvc-application-and-reduce-code-smell.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/rashid/archive/2009/02/17/use-bootstrapper-in-your-asp-net-mvc-application-and-reduce-code-smell.aspx</a>
  ), but UnityContainer implements IDisposable and in that example it is never cleaned up. This (<a href="https://stackoverflow.com/questions/1807298/configuring-automapper-in-bootstrapper-violates-open-closed-principle/1810728#1810728">Configuring Automapper in Bootstrapper violates Open-Closed Principle?</a>)  is also a decent example, but he doesn't deal with the Unity/Disposable problem either.</p>
  
  <p>Here's (<a href="http://www.dominicpettifer.co.uk/Blog/42/put-an-ioc-powered-bootstrapper-in-your-asp-net-mvc-application" rel="nofollow noreferrer">http://www.dominicpettifer.co.uk/Blog/42/put-an-ioc-powered-bootstrapper-in-your-asp-net-mvc-application</a>) another great example of how to do a Bootstrapper, but again doesn't address the Unity/Disposable issue.</p>
  
  <p>I thought about keeping my Bootstrapper object around in a static variable and make it implement IDisposable, but that doesn't sound right.</p>