title: The factory was disposed and can no longer be used. NHibernatefacility
body: <p>I have been trying for three days to figure out this NHibernatefacility thing with Castle and wcf and it's really getting frustrating.</p>
  
  <p>After solving a good dozen of errors, i have come to this one which seems pretty obvious but i can't solve.</p>
  
  <p>This is my global.asax's Application_Start</p>
  
  <pre><code>        container.AddFacility&lt;AutoTxFacility&gt;();
          container.Register(Component.For&lt;INHibernateInstaller&gt;().ImplementedBy&lt;NHibernateInstaller&gt;());
          container.AddFacility&lt;NHibernateFacility&gt;();
          container.AddFacility&lt;WcfFacility&gt;();
  
          container.Register(
              Component.For&lt;IAuthService&gt;().ImplementedBy&lt;AuthService&gt;().LifestylePerWcfOperation(),
              Component.For&lt;IUserRepository&gt;().ImplementedBy&lt;UserRepository&gt;().LifestylePerWcfOperation(),
              Component.For&lt;IActionWebService&gt;().ImplementedBy&lt;ActionWebService&gt;().Named("ActionWebService").LifestylePerWcfOperation(),
              Component.For&lt;ISession&gt;().LifeStyle.PerWcfOperation().UsingFactoryMethod(x =&gt; container.Resolve&lt;ISessionManager&gt;().OpenSession()));
  </code></pre>
  
  <p>This works for the first request. After that, it comes up with this error.</p>
  
  <p><strong>The factory was disposed and can no longer be used.
  Object name: 'this'.</strong></p>
  
  <p>the error is happening in my userrepository in this line</p>
  
  <pre><code>[Transaction]
          public virtual User GetUserByCredentials(string email, string password)
          {
              using (var tx = session())
              {
                  return tx.QueryOver&lt;User&gt;().Where(x =&gt; x.Email == email &amp;&amp; x.Password == password).SingleOrDefault();
              }
          }
  </code></pre>
  
  <p>I am having a feeling this has to do with the LIfestyle. I have tried multiple combinations but unsuccessful. I don't know what to do at this point. I got into this Castle thing with all the facilities (that are supposed to make life easier) and it's really complicated due to the lack of documentation. I haven't been able to find a descent guide to implement all of this together, not to mention something that is not 4 years old. </p>
  
  <p>Help Please!</p>