title: Fluent NHibernate - exception occurred during configuration of persistence layer
body: <p>I am using Fluent NHibernate with an external 'hibernate.cfg.xml' file.</p>
  
  <p>Following is the configuration code where I am getting error:</p>
  
  <pre><code>       var configuration = new Configuration();
         configuration.Configure();
  
         _sessionFactory = Fluently.Configure(configuration)
                  .Mappings(m =&gt; m.FluentMappings.AddFromAssemblyOf&lt;Template&gt;())
                  .BuildSessionFactory();
  
          return _sessionFactory;
  </code></pre>
  
  <p>But When NHibernate is trying to configure, I am getting floowing error:</p>
  
  <p>An exception occurred during configuration of persistence layer.</p>
  
  <p>The inner exception says:</p>
  
  <blockquote>
    <p>The ProxyFactoryFactory was not configured.
    Initialize 'proxyfactory.factory_class' property of the session-factory configuration section with one of the available NHibernate.ByteCode providers.</p>
  </blockquote>
  
  <p>I googled and according to some solutions I found, I have made following changes:</p>
  
  <ol>
  <li><p>Add following dlls to my app bin: </p>
  
  <p>Castle.Core.dll, Castle.DynamicProxy2.dll, NHibernate.ByteCode.Castle.dll</p></li>
  <li><p>Added follwing property in hibernate.cfg.xml  </p>
  
  <p>&lt;property name="proxyfactory.factory_class"&gt;NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle&lt;/property&gt;</p></li>
  </ol>
  
  <p>But still I am getting the same exception.</p>