I have a Typed Factory in Castle Windsor registered like
container.Register(Component.For<IMyTypeFactory>().AsFactory());
and the interface registered like
container.Register(Component.For<IMyType>()
.ImplementedBy<MyType>().LifestyleTransient()
.Interceptors(typeof(MyInterceptor));
I have also registered the facility like
if (!container.Kernel.GetFacilities().Any(f => f is TypedFactoryFacility))
{
container.AddFacility<TypedFactoryFacility>(); // Due to the debugger this line is reached.
}
When I try to resolve an instance of IMyClass like
var myFactory = container.Resolve<IMyFactory>();
var myClass = myFactory.GetMyClass(myParameter); // This is where I get the exception
an exception is thrown with the message
Castle.MicroKernel.ComponentNotFoundException: 'Requested component named 'IMyClass' was not found in the container. Did you forget to register it?
There is one other component supporting requested service 'The.Name.Space.IMyClass'. Is it what you were looking for?'
My IMyTypeFactory looks like this:
public interface IMyTypeFactory
{
IMyType GetIMyType(IMyParameter myParameter);
}
MyType constructor looks like this:
public MyType(
IOneProperlyResolvedType oneProperlyResolvedType,
IAnotherProperlyResolvedType anotherProperlyResolvedType,
IMyParameter myParameter)
{
this.oneProperlyResolvedType = oneProperlyResolvedType;
this.anotherProperlyResolvedType = anotherProperlyResolvedType;
this.myParameter = myParameter;
}