I am using Fluent NHibernate with an external 'hibernate.cfg.xml' file.
Following is the configuration code where I am getting error:
var configuration = new Configuration();
configuration.Configure();
_sessionFactory = Fluently.Configure(configuration)
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Template>())
.BuildSessionFactory();
return _sessionFactory;
But When NHibernate is trying to configure, I am getting floowing error:
An exception occurred during configuration of persistence layer.
The inner exception says:
The ProxyFactoryFactory was not configured. Initialize 'proxyfactory.factory_class' property of the session-factory configuration section with one of the available NHibernate.ByteCode providers.
I googled and according to some solutions I found, I have made following changes:
Add following dlls to my app bin:
Castle.Core.dll, Castle.DynamicProxy2.dll, NHibernate.ByteCode.Castle.dll
Added follwing property in hibernate.cfg.xml
<property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
But still I am getting the same exception.
I had this error too. It fires when you don't copy the mapping file (hibernate.cfg.xml) to the build directory.
Solution:
As Alex InTechno said, this might be the error in the definition of your Mapping files or in mapped entities. I experienced the same error, when I have forgot that all properties in mapped classes have to be defined as virtual.
public String Name {get;set;}
public virtual String Name { get; set; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With