Archive For The “Unity” Category

Workaround for combining a factory method and Lifetime Manager with Unity

Today I encountered a pretty basic scenario that Unity can’t support out of the box: one NHibernate ISession per HttpContext. The problem is that ISessions are provided by a factory method NHibernateHelper.OpenSession(), and I need to store them in a custom HttpContextLifetimeManager. Unity won’t let me use the two together because no RegisterFactory() overload allows […]

Read more »

IUnityContainerAccessor must use a static container instance

I found an interesting problem this morning when my ASP.NET MVC application mysteriously broke after adding an HttpModule in the web.config. Here’s the problem code: The container was being configured fine in Application_Start, but then UnityControllerFactory would throw “The container seems to be unavailable in your HttpApplication subclass” exceptions every time you tried to load […]

Read more »