0
votes

I am developing an application using MVC 3 and Castle Windsor, among others of course. I am having trouble getting Windsor to instantiate more than one object - even though the service might be registered with Transient or PerWebRequest.

container.Register(Component.For<ISession>().LifestylePerWebRequest().ImplementedBy<SessionImpl>());

This is all the relevant code as far as I'm aware. Resolving for ISession works fine, receiving a SessionImpl object.

SessionImpl is just a dummy object I created to show the problem:

public class SessionImpl : ISession
{
    public SessionImpl()
    {
         //Called once   
    }

    public void Dispose()
    {
        //Called once 
    }
}

I first noticed the problem when the ISession I got on the next request was already disposed - so I am sure I am getting the same ISession every time. Any ideas what I can have done wrong? It says Castle Windsor 3.0.0 in Solution Explorer -> References.

1

1 Answers