Component creation as defined factory

26 views
Skip to first unread message

Doruk Dalçam

unread,
Dec 5, 2017, 8:19:01 AM12/5/17
to Castle Project Users
Hi, I have an component which is registered as

container.Register(Component.For<IConnectorFactory>().AsFactory().LifestyleTransient());
container.Register(Component.For(typeof(JConnector<>)).LifestyleTransient());

And exception text is like this; (Normally I expect that exception message include necessary missing things. But this time no inner exception and no further info.)

Can't create component 'JConnector<>' as it has dependencies to be satisfied.

   at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden)
   at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired)
   at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context)
   at Castle.MicroKernel.Handlers.DefaultGenericHandler.Resolve(CreationContext context, Boolean instanceRequired)
   at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context)
   at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, IDictionary additionalArguments, IReleasePolicy policy)
   at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, IDictionary arguments, IReleasePolicy policy)
   at Castle.MicroKernel.DefaultKernel.Resolve(Type service, IDictionary arguments)
   at Castle.Windsor.WindsorContainer.Resolve[T]()
   at JawwalCrm.Bootstrapper.Common.WindsorServiceLocatorAdapter.Resolve[TService]() in WindsorServiceLocatorAdapter.cs:line 21


Can you help me to resolve the issue? At least how to track it? Ideas or anything else would be great?

Krzysztof Koźmic

unread,
Dec 5, 2017, 8:27:52 AM12/5/17
to castle-pro...@googlegroups.com
Hi Doruk

You're right, I would expect more details there. If you can run that code with a debugger attached, what do you see in the debugger view on the container (https://github.com/castleproject/Windsor/blob/master/docs/debugger-views.md)

--
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-u...@googlegroups.com.
To post to this group, send email to castle-pro...@googlegroups.com.
Visit this group at https://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/d/optout.
--

sent from my phone
Krzysztof

Message has been deleted

Doruk Dalçam

unread,
Dec 5, 2017, 9:11:12 AM12/5/17
to Castle Project Users

here is the debugger. thanks for help. it says all registered components are ok. And by the way web client using the same code is running but windows client is crashing if this info helps.
submitter.jpg

Doruk Dalçam

unread,
Dec 5, 2017, 11:46:03 AM12/5/17
to Castle Project Users
After trying all the solutions nearly 8 hours I initialized all types and subtypes in the project. And change initialization order. Then I found there is a dependency JConnector<T> of T so I registered all T's and initialized aaand voila! 

So be careful if you have dependencies like me. Windsor is not giving any detailed info about registered but not initialized components. It seems only collecting resolution conflicts and gaps. Any initialization or chain based mistakes will be welcomed in a dark room :) 

Have a nice day.

Jonathon Rossi

unread,
Dec 7, 2017, 3:07:26 AM12/7/17
to castle-pro...@googlegroups.com
So be careful if you have dependencies like me. Windsor is not giving any detailed info about registered but not initialized components. It seems only collecting resolution conflicts and gaps. Any initialization or chain based mistakes will be welcomed in a dark room :)

If you can could you put together a unit test for this scenario, we've already got quite a few unit tests for unsatisfied dependencies so it would be good to get this defect in error reporting fixed. A pull request with a unit test would be great.

--
Reply all
Reply to author
Forward
0 new messages