Castle Windsor: UsingFactoryMethod cannot create instance with unusual error

When I use this posting:

container.Register(
    Component
        .For<IFooFactory>()
        .ImplementedBy<FooFactory>(),
    Component
        .For<IFoo>()
        .UsingFactoryMethod(kernel => kernel.Resolve<IFooFactory>().CreateFoo())
);

I get this exception:

Castle .MicroKernel.ComponentRegistrationException: Type MyNamespace.IFoo is abstract. Therefore, it is not possible to install it as an implementation of the MyNamespace.IFoo service

I am not sure what the problem is. But the stack trace shows that in "DefaultComponentActivator.CreateInstance ()" the following condition is successful, and then an error is thrown:

if (createProxy == false && Model.Implementation.IsAbstract)

Do I need some kind of proxy server? Registration error?

+4
source share
1 answer

From the message, it seems you have not registered IFooFactory.

factory. , :

container.AddFacility<Castle.Facilities.FactorySupport.FactorySupportFacility>();
+10

All Articles