Hmm, you might need to register the collection as a component or customise
the lazy resolver.

I'm on holidays without laptop so can't really look into the code right now

Krzysztof Kozmic
sent from my phone
On 14 Mar 2013 00:43, "Fabrice" <faze1...@gmail.com> wrote:

> I only upgrade when I've a reason to ... which I have now :-)
>
> So I upgraded from 3.0 to 3.2 without any problem.
>
> But it seems registering explicitly Lazy doesn't fix the problem, I still
> have the "No component for supporting the service
> DF.MailFlow.WorkerService.IScheduler[] was found" error.
>
> Here is how my container is configured:
>
>             // Create container
>             this.container = ContainerTools.InitializeContainer(); // it
> just create the container
>
>             // Handle collection & array
>             this.container.Kernel.Resolver.AddSubResolver(new
> CollectionResolver(this.container.Kernel, true));
>
>             // Add facilities
>             this.container.AddFacility<LoggingFacility>(f =>
> f.LogUsing(LoggerImplementation.Log4net).WithConfig("logging.config"));
>
> this.container.AddFacility<Castle.Facilities.Startable.StartableFacility>();
>
>             // Get a logger to log when components are registered
>             this.Logger = this.container.Resolve<ILogger>();
>
>             // Register lazy loading
>             this.container.Register(
>                 Component.For(typeof(Lazy<>))
>
> .ImplementedBy(typeof(Castle.MicroKernel.Internal.LazyEx<>),
> Castle.MicroKernel.Internal.LazyServiceStrategy.Instance)
>                     .LifeStyle.Transient);
>
> (... some other registrations ...)
>
>             // Register scheduler components
>             this.container.Register(Classes
>                 .FromThisAssembly()
>                 .IncludeNonPublicTypes()
>                 .BasedOn<IScheduler>()
>                 .WithService.FromInterface(typeof(IScheduler))
>                 .LifestyleTransient());
>
>
> Then, I've the error when I try to resolve a component with this
> constructor:
>
> public CompanyComponent(ILogger logger, Lazy<IScheduler[]> schedulers)
>
>
> Do you have any idea ?
>
> Thank you
> Fabrice
>
>
>
> On Wed, Mar 13, 2013 at 2:55 AM, Krzysztof Koźmic <
> krzysztof.koz...@gmail.com> wrote:
>
>> Yup, it's a 3.1+ thing.
>>
>> Why not upgrade?
>>
>> Krzysztof Kozmic
>> sent from my phone
>> On 12 Mar 2013 20:58, "Fabrice" <faze1...@gmail.com> wrote:
>>
>>> Hello Krzysztof,
>>>
>>> Sorry for not replying before, but I was waiting for a branch in our
>>> source code before testing that (as we were close to a release)
>>> As we currently only have one kind of array, I registered this array
>>> manually (as a work around):
>>>
>>> container.Register(Component.For<IScheduler[]>()
>>>                                 .UsingFactoryMethod(kernel =>
>>> kernel.ResolveAll<IScheduler>())
>>>                                 .LifestyleTransient());
>>>
>>> Now the branch is done, so I'm trying to find a global solution for all
>>> kind of arrays
>>>
>>> I've tried your solution, but I don't find any LazyServiceStrategy type ?
>>>
>>> I'm using Windsor 3.0, so maybe it's something that came later ?
>>>
>>>
>>>
>>> On Tue, Feb 26, 2013 at 9:15 PM, Krzysztof Kozmic <
>>> krzysztof.koz...@gmail.com> wrote:
>>>
>>>>  Fabrice,
>>>>
>>>> This is a known limitation.
>>>>
>>>> I think it may work however, if you register support for lazy explicitly
>>>>
>>>> Component.For(typeof(Lazy<>))
>>>>  .ImplementedBy(typeof(LazyEx<>), LazyServiceStrategy.Instance)
>>>> .LifeStyle.Transient
>>>>
>>>> instead of LazyOfTComponentLoader
>>>>
>>>> --
>>>> Krzysztof Kozmic
>>>>
>>>> On Wednesday, 27 February 2013 at 1:47 AM, Fabrice wrote:
>>>>
>>>> Hi
>>>>
>>>> I've a CTor like this:
>>>> public CompanyComponent(ILogger logger, Lazy<IScheduler[]> schedulers)
>>>>
>>>> I've configured my container to add Lazy & Collection feature:
>>>>
>>>> this.container = new
>>>> DF.ApplicationBlocks.ApplicationContainer.Container(); // This is my
>>>> subclass of WindsorContainer
>>>>
>>>> // Handle collection & array
>>>> container.Kernel.Resolver.AddSubResolver(new
>>>> CollectionResolver(container.Kernel));
>>>>
>>>> // Register lazy loading
>>>>
>>>> container.Register(Component.For<ILazyComponentLoader>().ImplementedBy<LazyOfTComponentLoader>());
>>>>
>>>> These lines are set before registering any component.
>>>>
>>>> Then when I try to resolve the CompanyComponent:
>>>>
>>>> Castle.MicroKernel.ComponentNotFoundException was unhandled
>>>>   HelpLink=groups.google.com/group/castle-project-users
>>>>   HResult=-2146233088
>>>>   Message=No component for supporting the service
>>>> DF.MailFlow.WorkerService.IScheduler[] was found
>>>>   Source=Castle.Windsor
>>>>
>>>> If I use DebuggerVisualizer:
>>>> Some dependencies of this component could not be statically resolved.
>>>> 'DF.MailFlow.WorkerService.CompanyComponent' is waiting for the
>>>> following dependencies:
>>>> - Service 'System.Lazy`1[[DF.MailFlow.WorkerService.IScheduler[],
>>>> DF.MailFlow.WorkerService, Version=2.0.0.0, Culture=neutral,
>>>> PublicKeyToken=1eb1c673988515c1]]' which was not registered.
>>>>
>>>> To know if the problem was coming from Lazy or from Array, using
>>>> immediate window I've tried to resolve:
>>>> - IScheduler : succeeded
>>>> - IScheduler[]: failed
>>>> - List<IScheduler>: failed
>>>> - IList<IScheduler>: failed
>>>> - Lazy<IScheduler>: succeeded
>>>>
>>>> So it's seems it comes from the array. I've also tried using the "old"
>>>> ArrayResolver, but same problem. I've added 2 screenshot with more details
>>>> on the container content and on the exception.
>>>>
>>>> I've 6 IScheduler component registered, so does someone have an idea on
>>>> why it throw this exception ?
>>>>
>>>> Thank you
>>>> Fabrice
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Castle Project Users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to castle-project-users+unsubscr...@googlegroups.com.
>>>> To post to this group, send email to
>>>> castle-project-users@googlegroups.com.
>>>> Visit this group at
>>>> http://groups.google.com/group/castle-project-users?hl=en.
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>>
>>>>
>>>> Attachments:
>>>>  - 2013-02-26_16h29_41.png
>>>>  - 2013-02-26_16h27_01.png
>>>>
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Castle Project Users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to castle-project-users+unsubscr...@googlegroups.com.
>>>> To post to this group, send email to
>>>> castle-project-users@googlegroups.com.
>>>> Visit this group at
>>>> http://groups.google.com/group/castle-project-users?hl=en.
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>>
>>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Castle Project Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to castle-project-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to
>>> castle-project-users@googlegroups.com.
>>> Visit this group at
>>> http://groups.google.com/group/castle-project-users?hl=en.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Castle Project Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to castle-project-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to
>> castle-project-users@googlegroups.com.
>> Visit this group at
>> http://groups.google.com/group/castle-project-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Castle Project Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to castle-project-users+unsubscr...@googlegroups.com.
> To post to this group, send email to castle-project-users@googlegroups.com
> .
> Visit this group at
> http://groups.google.com/group/castle-project-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to castle-project-users+unsubscr...@googlegroups.com.
To post to this group, send email to castle-project-users@googlegroups.com.
Visit this group at http://groups.google.com/group/castle-project-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to