Hi Ken,

On 25 Set, 09:27, Ken Egozi <[email protected]> wrote:
> @Carmine - is there any chance that multiple instances of your application
> are being started - thus you get multiple containers?the container should be
> held as a static instance, and instantiated once per app domain

Let me state that at the beginning it was the Kernel that got passed
around to all
components partecipating in the application. Then I switched to
passing the WindsorContainer
thinking the kernel might have been the "culprit". Obviously I was
wrong.

I don't think this happens because the container gets created upon
application launch (in Program.cs)
where the following things happens:

IWindsorContainer container = new WindsorContainer();
container.AddComponent<IApplicationFacade, ApplicationFacade>
("applicationFacade");
container.AddComponent<MainForm>("mainForm");

MainForm mf = container.Resolve<MainForm>("mainForm");

Then the usual stuff in Program.cs happens which launches the
MainForm.

MainForm's constructor has the following signature:

MainForm(IWindsorContainer container)

And it gets called as expected.

In the above mentioned constructor, the following things happens:

IApplicationFacade = _container.Resolve<IApplciationFacade>
("applicationFacade");

Which triggers the instantiation of ApplicationFacade's instance.
ApplicationFacade's constructor has the following signature:
ApplicationFacade(IWindsorContainer container)

Its main purpose is to load any plugin and/or service it finds in the
application folder.
Both plugins and services have constructors with only one requirement:
the "global" container.
Plugins and services constructor does:

_container.AddComponent<IMyServiceInterface,MyServiceClass>
("myServiceName");
_facade = _container.Resolve<IApplicationFacade>("applicationFacade");

Now, since the first time "applicationFacade" was requested it
happened in the MainForm's constructor, I
here expect to receive the already instantiated singleton since all of
those plugins and services are loaded
in the default application domain.
Instead, tracing step by step, I discovered that the
ApplicationFacade's constructor gets called each and every
time the container is asked to resolve.

To my newbie's eyes, it seems that I do nothing wrong.
I beg your pardon but I couldn't post code for two reasons:

1. Source code's at home :)
2. I thought it was too much for a post. So, if you think that seeing
actual code might be of some help,
please, feel free to ask.

Thanks again for all your precious help.
Regards, Carmine
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to