Actually it seems my original problem was having IKernel as a
dependency.
I changed it to be IWindsorContainer and added the following line in
global:
            container = new WindsorContainer(new XmlInterpreter());
            container.Register(Component.For<IWindsorContainer>
().Instance(container));

Regarding putting the session in the container, which custom
dependencies collection do you refer to?

Right now I do have a problem with the container releasing the
session:

        public void ReleaseInstance(InstanceContext instanceContext,
object instance)
        {
            if (session != null)
            {
                container.Release(session);
                session.Close();
                session = null;
            }
        }


On Jun 2, 5:03 pm, Craig Neuwirt <[email protected]> wrote:
> I can't remember the exact details of the NHib Facility, but it does seem a
> little unusual to put the ISession in the container.   WHen you resolve the
> instance, may you should add the ISession in the custom dependnecies
> collection and do a Resolve with the custom dependencies.
>
> On Tue, Jun 2, 2009 at 10:50 AM, Andyk <[email protected]> wrote:
>
> > Well, I think the problem is simply that Im adding a session generated
> > by the SessionManager, into the container, but its not resolving it
> > later on.
> > A test case might look like:
>
> >       [Test]
> >       public void Should_resolve_session_provided_by_SessionManager()
> >        {
> >            IKernel kernel = new DefaultKernel();
> >            kernel.Register(Component.For<ITestService>
> > ().ImplementedBy<TestService>());
>
> >            var session = sessionManager.OpenSession();
> >            kernel.AddComponentInstance("NHibernate.Session",session);
>
> >            var result = kernel.Resolve<ITestService>();
> >        }
>
> >        public class TestService:ITestService
> >        {
> >            private readonly ISession session;
>
> >            public TestService (ISession session)
> >            {
> >                this.session = session;
> >            }
>
> >            public void DoWork()
> >            {
> >                throw new NotImplementedException();
> >            }
> >        }
> >        public interface ITestService
> >        {
> >            void DoWork();
> >        }
>
> > Is this what you mean?
--~--~---------~--~----~------------~-------~--~----~
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