title: Help with ActiveRecord exception "Failed to lazily initialize a collection - no session"
body: <p>I am writing a web app using Castle ActiveRecord, and I keep getting this exception whenever I try to access a lazy loaded list of related objects.  Here is my code:</p>
  
  <pre><code>        using(new SessionScope())
          {
              foreach (var field in eventObj.RegistrationFields)
              {
                  //Do something with the field here...
              }
          }
  </code></pre>
  
  <p>The RegistrationFields property looks like this:</p>
  
  <pre><code>    [HasMany(Inverse = true, Lazy = true)]
      public IList&lt;EventRegistrationField&gt; RegistrationFields { get; set; }
  </code></pre>
  
  <p>The exception happens when the "eventObj.RegistrationFields" is accessed for the foreach loop.  I also made sure to set the isweb="true" attribute in my activeRecord config settings.  Does anyone know why this would happen?  Here is my config:</p>
  
  <pre><code>&lt;connectionStrings&gt;
    &lt;add name="main" connectionString="Data Source=localhost\SQLEXPRESS;Initial Catalog=EventScheduler;Integrated Security=SSPI"/&gt;
  &lt;/connectionStrings&gt;
  &lt;activerecord isWeb="true"&gt;
    &lt;config&gt;
      &lt;add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver"/&gt;
      &lt;add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2005Dialect"/&gt;
      &lt;add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/&gt;
      &lt;add key="hibernate.connection.connection_string_name" value="main"/&gt;
    &lt;/config&gt;
  &lt;/activerecord&gt;
  </code></pre>