Jul 30, 2012 at 4:15 PM
Edited Jul 30, 2012 at 4:18 PM
Yes, you should be able to to inject class library projects in a web application via configuration files. You just need to ensure that the configuration is set up, that in the web application call LoadConfiguration on
the UnityContainer, and ensure that the class library assemblies are resolvable by the container.
Your web.config configuration looks fine although you don't need the aliases since you also have assembly and namespace tags.
Where you set up the container depends on your design but if we assume that every user gets their own container (since your container is called session) then in global.asax you could create a container and save it so it can be accessed when required to resolve
public class Global : System.Web.HttpApplication
void Application_Start(object sender, EventArgs e)
IUnityContainer container = new UnityContainer();
Application["unityContainer"] = container;
void Session_Start(object sender, EventArgs e)
var container = Application["unityContainer"] as IUnityContainer;
Session["unityContainer"] = container.CreateChildContainer();
void Session_End(object sender, EventArgs e)
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
var container = Session["unityContainer"] as IUnityContainer;
var container = Session["container"] as IUnityContainer;
var presenter = container.Resolve<PlayViewPresenter>();
If you are encountering issues, could you provide more details about the exact scenario to reproduce the issue?
Enterprise Library support engineer