We have sharepoint application. Inside it several asp.net applications are deployed. The goal is to have separate enterprise library configuration per application. The enter point of using EntLib is Unity, so each application will have its own unity container
configured using its own enterprise library configuration file. We use Exception Handling, Policy Iinjection, Logging and Interception Application Blocks.
For now I have workable solution: in every application in application start (using httpModule) I create global unity container which is configurated using specific config-file:
private static IUnityContainer CreateContainer()
// create an instance of Unity container
IUnityContainer unityContainer = new UnityContainer();
// create the Unity configurator
IContainerConfigurator configurator = new UnityContainerConfigurator(unityContainer);
string configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "<ApplicationName_EntLib>.config");
// configure the container
EnterpriseLibraryContainer.ConfigureContainer(configurator, new FileConfigurationSource(configPath));
// manually create the service locator
IServiceLocator serviceLocator = new UnityServiceLocator(unityContainer);
// assign the service locator to Current
EnterpriseLibraryContainer.Current = serviceLocator;
But there is a potential problem with the line "EnterpriseLibraryContainer.Current = serviceLocator;".
Because all applications are under the same appDomain this is the common part for them all. But my goal is to separate container instances with their own entLib setting.
Is there any way to go in such a situation? What should I use instead
Thanks in advance.
(This is the repost from the EntLib forum