Thanks Michael!  I actually just ran into this exact same problem.  I
was totally baffled as to why my IStartable stopped starting up.  I
thought it was something I did until I realized the problem started
happening when I upgraded to the latest Windsor distro.  Like you
said, I changed my component from fluent registration to an explicit
AddComponent and, sure enough, it works like a charm!

tim


On Mar 29, 7:29 am, Michael Davis <[email protected]> wrote:
> I suspect that this may be the same problem I posted about on March 4
> ("Strange behavior with StartableFacility"), IOC-ISSUE-195.  If everything
> works as expected if you use c.AddComponent() to register your components
> instead of the c.Register() fluent interface, then it's definitely the same
> problem (and that can be a workaround you can use until it's fixed).
>
> I suggested a potential fix for the issue and offered to submit a patch, but
> I never heard back from anyone about what the preferred method for doing
> that would be since the code was moved to github.
>
> Michael Davis
>
> On Mon, Mar 29, 2010 at 7:14 AM, Konstantin <[email protected]>wrote:
>
>
>
> > the code of onHandlerStateChanged method  should be the following
>
> > private void onHandlerStateChanged(object source, EventArgs args)
> >        {
> >             OnHandlerStateChangedWasCalled = true;
> >         }
>
> > On Mar 29, 4:11 pm, Konstantin <[email protected]> wrote:
> > > Here is test demonstrating the issue
>
> > >         [Test]
> > >         public void Test()
> > >         {
> > >             var c = new WindsorContainer();
> > >             var myFacilty = new MyFacilty();
> > >             c.AddFacility("my", myFacilty);
> > >             c.Register(Component.For<A>());
> > >             Assert.AreEqual(HandlerState.WaitingDependency,
> > > myFacilty.Handlers["Tests.A"].CurrentState);
> > >             c.Register(Component.For<B>().Instance(new B()));
> > >             Assert.AreEqual(HandlerState.Valid,
> > > myFacilty.Handlers["Tests.A"].CurrentState);
> > >             var a = c.Resolve<A>();
> > >             Assert.IsTrue(myFacilty.OnHandlerStateChangedWasCalled,
> > > "OnHandlerStateChanged was not raised");
> > >         }
>
> > > //Classes used in test
>
> > > namespace Tests
> > > {
>
> > >     public class MyFacilty : AbstractFacility
> > >     {
> > >         public MyFacilty()
> > >         {
> > >             Handlers = new Dictionary<string, IHandler>();
> > >         }
>
> > >         protected override void Init()
> > >         {
> > >             Kernel.ComponentRegistered += KernelOnComponentRegistered;
> > >         }
>
> > >         private void KernelOnComponentRegistered(string key, IHandler
> > > handler)
> > >         {
> > >             Handlers.Add(key, handler);
> > >             if (handler.CurrentState ==
> > > HandlerState.WaitingDependency)
> > >             {
> > >                 handler.OnHandlerStateChanged +=
> > > onHandlerStateChanged;
> > >             }
> > >         }
>
> > >         private void onHandlerStateChanged(object source, EventArgs
> > > args)
> > >         {
> > >             Console.WriteLine("onHandlerStateChanged");
> > >         }
>
> > >         public bool OnHandlerStateChangedWasCalled { get; set; }
>
> > >         public Dictionary<string, IHandler> Handlers { get; set; }
> > >     }
>
> > >     public struct B
> > >     {
> > >     }
>
> > >     public class A
> > >     {
> > >         public A(B b)
> > >         {
> > >         }
> > >     }
>
> > > }
>
> > --
> > 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]<castle-project-users%2Bun 
> > [email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/castle-project-users?hl=en.

-- 
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