This is something that a few people (those who don't read release notes
) are going to run into, so i figured i'd post the solution here.
If your application uses NHibernate 2.0, and you want to upgrade to NHibernate 2.1 you need to add something to your NHibernate configuration. If you just replace NHibernate.dll with the newer version and start your application, you will get an exception with the following message:
The ProxyFactoryFactory was not configured. Initialize 'proxyfactory.factory_class' property of the session-factory configuration section with one of the available NHibernate.ByteCode providers. Example: <property name='proxyfactory.factory_class'>NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property> Example: <property name='proxyfactory.factory_class'>NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
Pretty helpful message, no? (if only everyone would actually read the content of exception messages)
NHibernate used to default to use Castle's DynamicProxy to generate runtime proxies, but you now have to explicitly state which proxy factory should be used.
For instance, if you want to use Castle's DynamixProxy, add a reference to NHibernate.ByteCode.Castle.dll to your project and add the following line to your hibernate.cfg.xml file:
<property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
If you want to use another proxy factory, add a reference to the correct one (for instance, NHibernate.ByteCode.LinFu.dll) and modify the property in the config file. A proxy factory which uses Spring will also be included soon.
Pingback: Reflective Perspective - Chris Alcock » The Morning Brew #307
Pingback: Upgrading to NHibernate 2.1 for new Validators! « Geospecialling