protected override IServiceProvider CreateServiceProvider() { var nss = new DelegateNamingSubSystem() { SubSystemHandler = (s, hs) => { if (hs.Any(h => h.ComponentModel.IsOverridable())) { var nonOverridable = hs.Except(hs.Where(h => h.ComponentModel.IsOverridable())); if (nonOverridable.Any()) { return(nonOverridable.Single()); } } return(null); } }; this.container = new Castle.Windsor.WindsorContainer(); this.container.Kernel.AddSubSystem(SubSystemConstants.NamingKey, nss); this.container.Kernel.Resolver.AddSubResolver(new ArrayResolver(this.container.Kernel, true)); var wrapper = new ServiceProviderWrapper(this.container); var bootConventions = new BootstrapConventions(); this.container.Register( Component.For <IServiceProvider>() .Instance(wrapper) .Properties(pi => bootConventions.IgnorePropertyInjection(pi)) ); this.container.Register(Component.For <IWindsorContainer>().Instance(this.container)); this.container.Register ( Component.For <BootstrapConventions>() .Instance(bootConventions) .Properties(pi => bootConventions.IgnorePropertyInjection(pi)) ); this.container.AddFacility <Castle.Facilities.SubscribeToMessageFacility>(); this.container.AddFacility <InjectViewInRegionFacility>(); return(wrapper); }