Unable to pass Windsor Typed Factory Facility parameter

I have an IRunningTaskFactory that is registered in Windsor AsFactory () using the Factory Typed Engine. The interface has a single method that looks like this:

RunningTask Create(ITask task); 

If RunningTask is registered as temporary in Windsor, it has a constructor:

 public RunningTask(ITask task, ITaskConfigurationFactory taskConfigurationFactory) 

where ITaskConfigurationFactory is also registered in Windsor.

The problem I am facing is that when I call the Create method and pass in ITask, I get the following error:

Castle.MicroKernel.Resolvers.DependencyResolverException: Missing dependency. The Husky.nHuskyTasker.Core.Tasks.RunningTask component has a dependency on Husky.nHuskyTasker.Core.Tasks.ITask that cannot be resolved. Make sure the dependency is correctly registered in the container as a service, or presented as an inline argument

From what I read in the documentation, this should work.

Thoughts?

+6
dependency-injection castle-windsor
source share
2 answers

I found that if you specify a dummy registration for a type with variable instances, then your parameter will be passed without errors:

 Component.For<ITask>().ImplementedBy<AnEmptyTask>() 

But I agree that this should work without such a mock implementation and additional registration.

Note that registering ITask will have a side effect of automatically posting Windsor to any public properties associated with this type that may be required to suppress

+1
source share

I had the same problem (the runtime parameter in a typed factory was not resolved), and it turned out that the parameter name on my factory and the constructor parameter name in the actual class were different, so when I called .Create () on the dialed factory, it could not resolve my parameter.

This topic has been resolved by release: Can Castle.Windsor TypedFactoryFacility build a type containing only some ref arguments passed inline?

Not obvious, but it makes sense.

+5
source share

All Articles