title: nhibernate configuration throws an exception
body: <p>During configuration of (persistance layer) nhibernate I get an exception. Message says that nhibernate couldn't find configuration file <code>hibernate.cfg.xml</code>. But I cheked my file and it's set to copy to output always. I store mappings and persistant classes in separate assembly. But both console project and class library project have the configuration file inside their outpt folder. </p>
  
  <p><strong>Config file</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"&gt;
    &lt;session-factory&gt;
      &lt;property name="connection.provider"&gt;
        NHibernate.Connection.DriverConnectionProvider
      &lt;/property&gt;
      &lt;property name="dialect"&gt;
        NHibernate.Dialect.MsSql2008Dialect
      &lt;/property&gt;
      &lt;property name="connection.driver_class"&gt;
        NHibernate.Driver.SqlClientDriver
      &lt;/property&gt;
      &lt;property name="connection.connection_string"&gt;
        Data Source=(local); Initial Catalog=KrossThoughtDB;
        Integrated Security=SSPI
      &lt;/property&gt;
      &lt;property name="show_sql"&gt;
        true
      &lt;/property&gt;   
      &lt;mapping resource="MyApp.Domain.Model.Entities.Mappings.User.hbm.xml"   assembly="MyApp.Domain" /&gt;
      &lt;mapping resource="MyApp.Domain.Model.Entities.Mappings.Blog.hbm.xml" assembly="MyApp.Domain" /&gt;
      &lt;mapping resource="MyApp.Domain.Model.Entities.Mappings.Post.hbm.xml" assembly="MyApp.Domain" /&gt;
      &lt;mapping resource="MyApp.Domain.Model.Entities.Mappings.Category.hbm.xml" assembly="MyApp.Domain" /&gt;
      &lt;mapping resource="MyApp.Domain.Model.Entities.Mappings.Feedback.hbm.xml" assembly="MyApp.Domain" /&gt;
    &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>Also I use the NHibernate session helper implementation that was provided in official documentation on NHibernate.</p>
  
  <p><strong>Session Helper</strong></p>
  
  <pre><code>public sealed class SessionHelper
  {
      private const String CurrentSessionKey = "nhibernate.current_session";
      private static readonly ISessionFactory sessionFactory;
  
      static SessionHelper()
      {
          sessionFactory = new Configuration().
              Configure().
              BuildSessionFactory();
      }
  
      public static ISession GetCurrentSession()
      {
          var context = HttpContext.Current;
          var currentSession = context.Items[CurrentSessionKey] as ISession;
  
          if(null == currentSession)
          {
              currentSession = sessionFactory.OpenSession();
              context.Items[CurrentSessionKey] = currentSession;
          }
  
          return currentSession;
      }
  
      public static void CloseSession()
      {
          var context = HttpContext.Current;
          var currentSession = context.Items[CurrentSessionKey] as ISession;
  
          if(null == currentSession)
          {               
              return;
          }
  
          currentSession.Close();
          context.Items.Remove(CurrentSessionKey);
      }
  
      public static void CloseSessionFactory()
      {
          if(null != sessionFactory)
          {
              sessionFactory.Close();
          }
      }
  }
  </code></pre>
  
  <p>And then I call this code inside my sample console application</p>
  
  <p><strong>Client code</strong></p>
  
  <pre><code>private static void Main(String[] args)
  {
      // the next line exception's thrown
      using(var session = SessionHelper.GetCurrentSession())
      using(var tx = session.BeginTransaction())
      {
          // some actions...
          tx.Commit();
      }
  }
  </code></pre>
  
  <p>Help!</p>