I’m having an issue with Castle Windsor 3 Beta 1. I’m using the ArrayResolver which has been added to the installer like so:
objContainer.Kernel.Resolver.AddSubResolver(New ArrayResolver(objContainer.Kernel, True))
From there I am registering a component and trying to inject an array of IWorkers. The IWorkers have their own dependencies. In the case where only one IWorker is specified, its dependencies are resolved- but when multiple are passed in this does not happen.
This won’t work:
objContainer.Register(Component.For(Of Services.INotifiableService).ImplementedBy(Of Services.MyService).Named(GetType(Services.MyService).Name).DependsOn(Dependency.OnComponent(GetType(Services.Resolvers.IResolver), GetType(Services.Resolvers.MyResolver).Name), Dependency.OnComponentCollection(Of Services.Workers.IWorker())(GetType(Services.Workers.IWorkerImplementationA), GetType(Services.Workers.IWorkerImplementationB))).Interceptors(Of Logging.Interceptors.InfoLoggingInterceptor, Notifications.Interceptors.ServiceErrorInterceptor).LifeStyle.Transient())
This will:
objContainer.Register(Component.For(Of Services.INotifiableService).ImplementedBy(Of Services.MyService).Named(GetType(Services.MyService).Name).DependsOn(Dependency.OnComponent(GetType(Services.Resolvers.IResolver), GetType(Services.Resolvers.MyResolver).Name), Dependency.OnComponentCollection(Of Services.Workers.IWorker())(GetType(Services.Workers.IWorkerImplementationA))).Interceptors(Of Logging.Interceptors.InfoLoggingInterceptor, Notifications.Interceptors.ServiceErrorInterceptor).LifeStyle.Transient())
Am I missing something simple or is this a bug?
Apologies – after further investigation I noticed an issue where certain components were not registering. This code now works correctly.