Why is my Windsor Implicit Delegate Factory Registration not working?

c#, castle-windsor, ioc-container

Solution

You're missing `TypedFactoryFacility`.

container.AddFacility<TypedFactoryFacility>()

Problem

I am trying to get this to work - but I must be missing something http://docs.castleproject.org/Windsor.Typed-Factory-Facility-delegate-based-factories.ashx#Registering_factories_implicitly_1 Can anyone spot it? ``` [TestClass] public class UnitTest1 { [TestMethod] public void DelegateFactoryTest() { var container = new WindsorContainer(); container.Register( Component.For<AComponent>().LifeStyle.Transient, Component.For<IAService>().ImplementedBy<AService>().LifeStyle.Transient ); var comp = container.Resolve<AComponent>(); Assert.IsNotNull(comp); Assert.IsNotNull(comp.GetService()); } class AComponent { readonly Func<IAService> _serviceDelegate; public AComponent(Func<IAService> serviceDelegate) { _serviceDelegate = serviceDelegate; } public IAService GetService() { return _serviceDelegate(); } } interface IAService { } class AService : IAService { } } ``` get the following error Castle.MicroKernel.Handlers.HandlerException: Can't create component 'Sandbox.Windsor.Tests.UnitTest1+AComponent' as it has dependencies to be satisfied. 'Sandbox.Windsor.Tests.UnitTest1+AComponent' is waiting for the following dependencies: - Service 'System.Func`1[[Sandbox.Windsor.Tests.UnitTest1+IAService, Sandbox.Windsor.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' which was not registered. if I explicitly register, all is well ``` container.Register( Component.For<AComponent>().LifeStyle.Transient, Component.For<IAService>().ImplementedBy<AService>().LifeStyle.Transient, Component.For<Func<IAService>>().Instance(()=>new AService()).LifeStyle.Transient ); ```

Original source