views:

112

answers:

1

I realize that NHibernate 2.1 removed its dependency on the Castle Project. In fact, Joshua Ewer did a great post summarizing the necessity of a proxy factory for an NHibernate implementation.

Presently, I am working through the examples in ASP.NET MVC in Action by Jeffrey Palermo and am confused. The source code examples for both the Chapter 13 NHibernate project and the Code Camp Server project are using NHibernate 2.1.0.1001. Neither project specifies proxyfactory.factory_class in its hibernate.cfg.xml. I am using NHibernate 2.1.0.4000 and am receiving the infamous "The ProxyFactoryFactory was not configured" error message.

I was under the impression that the proxyfactory.factory_class had to be specified in all revisions of NHibernate 2.1. Am I missing something in the provided examples that is specifying proxyfactory.factory_class outside of the hibernate.cfg.xml?

+1  A: 

I spent way too much time digging into this, but it was mostly enjoyable.

I found the source code for the ASP.NET MVC in Action book here:

http://www.manning.com/palermo/aspnetmvcinaction.zip

The NHibernate.dll available in the source code is dated December 26, 2008 and the version number is listed as "2.1.0.1001".

NHibernate 2.1 was officially released on July 19, 2009:

http://nhforge.org/blogs/nhibernate/archive/2009/07/19/welcome-nh2-1-0.aspx

So, this December 26, 2008 version is obviously not the final 2.1 release, but some pre "2.1 final" release.

Many of the changes around removing the hard dependency on Castle ProxyFactory were made on October 11, 2008 (specifically revisions between approximately 3840 and 3850). See also:

http://nhforge.org/blogs/nhibernate/archive/2008/10/11/nh2-1-0-reference-to-castle-removed.aspx

Using Reflector on the 2.1.0.1001 DLL shows a class here:

NHibernate.Bytecode.DefaultProxyFactoryFactory

This class was deleted by version 3844 in the source, so therefore this version of the NHibernate DLL is (at least partially) from before the removal of the hard dependency changes for Castle ProxyFactory were fully implemented.

It appears that the 2.1.0.1001 version number was placed on the DLL in revision 3850, so that leads me to believe this particular DLL may have been slightly hacked together with some source code from before 3844 and some source code from after 3844.

In any case, this DLL definitely seems to still contain the hard (and automatic) dependency on the Castle ProxyFactory, which explains why you don't need the proxyfactory.factory_class configuration entry.

Michael Maddox
I can't thank you enough for breaking this down for me. I sincerely hope it helps someone else as well. It's an answer like this that makes me wonder what we all did prior to Stack Overflow.
ahsteele