in my asp.net-mvc application I have a statis MvcApplication that calls a static CreateContainer() method.
In this method I create my unity ioc container:
private static IUnityContainer CreateContainer()
{
var container = new UnityContainer();
container.RegisterType<IConfigurationService, ConfigFile>();
container.RegisterType<ILoggerService, NlogLoggerService>();
container.RegisterInstance<ISearchService>(
new LuceneSearchService(
container.Resolve<IConfigurationService>(),
container.Resolve<ILoggerService>()),
new ContainerControlledLifetimeManager());
}
If I understood my sources well, this should give me a singleton LuceneSearchService instance. In my logging however, I can see that my constructor gets hit everytime this instance is requested.
What am I doing wrong?