title: NHibernate unable to create SessionFactory
body: <p>I'm having a bit of trouble setting up NHibernate, and I'm not too sure what the problem is exactly. I'm attempting to save a domain object to the database (Oracle 10g XE). However, I'm getting a TypeInitializationException while trying to create the ISessionFactory. Here is what my hibernate.cfg.xml looks like:</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 name="MyProject.DataAccess"&gt;
          &lt;property name="connection.driver_class"&gt;NHibernate.Driver.OracleClientDriver&lt;/property&gt;
          &lt;property name="connection.connection_string"&gt;
              User ID=myid;Password=mypassword;Data Source=localhost
          &lt;/property&gt;
          &lt;property name="show_sql"&gt;true&lt;/property&gt;
          &lt;property name="dialect"&gt;NHibernate.Dialect.OracleDialect&lt;/property&gt;
          &lt;property name="proxyfactory.factory_class"&gt;NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu&lt;/property&gt;
          &lt;mapping resource="MyProject/Domain/User.hbm.xml"/&gt;
      &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>I created a DAO which I will use to persist domain objects to the database. The DAO uses a HibernateUtil class that creates the SessionFactory. Both classes are in the DataAccess namespace along with the Hibernate configuration. This is where the exception is occuring. Here's that class:</p>
  
  <pre><code>public class HibernateUtil
  {
      private static ISessionFactory SessionFactory = BuildSessionFactory();
  
      private static ISessionFactory BuildSessionFactory()
      {
          try
          {
              // This seems to be where the problem occurs
              return new Configuration().Configure().BuildSessionFactory();
          }
          catch (TypeInitializationException ex)
          {
              Console.WriteLine("Initial SessionFactory creation failed." + ex);
              throw new Exception("Unable to create SessionFactory.");
          }
      }
  
      public static ISessionFactory GetSessionFactory()
      {
          return SessionFactory;
      }
  }
  </code></pre>
  
  <p>The DataAccess namespace references the NHibernate DLLs. This is virtually the same setup I've used with Hibernate in Java, so I'm not entirely sure what I'm doing wrong here. Any ideas?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>The innermost exception is the following:</p>
  
  <p>"Could not find file 'C:\Users\Tyler\Documents\Visual Studio 2010\Projects\MyProject\MyProject\ConsoleApplication\bin\Debug\hibernate.cfg.xml'."</p>
  
  <p>ConsoleApplication contains the entry point where I've created a User object and am trying to persist it with my DAO. Why is it looking for the configuration file there? The actual persisting takes place in the DAO, which is in DataAccess. Also, when I add the configuration file to ConsoleApplication, it still does not find it.</p>