4

I am building an application using NHibernate. Because I could not add the DLL's of my current version of NHibernate (I cannot add reference when framework 4.0 is target).

I tried to get the latest and greatest of the w.w.w., this is what I have now:

  • NHibernate.dll (3.2.0.4000)
  • NHibernate.ByteCode.Castle (3.0.0.4000)
  • FluentNHibernate.dll (1.2.0.694)
  • Castle.Core (2.5.2.0)
  • Castle.Services.Logging.NLogIntegration (2.5.2.0)
  • Antlr.Runtim (3.1.3.42154)
  • Iesi.Collections (3.2.0.400)

These I can reference and build my solution with. I know there are some issues with the copying/loading of the dll.s so I made them deployment items. But run-time I (still) get the following:

NHibernate.Bytecode.UnableToLoadProxyFactoryFactoryException: Unable to load type 'NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle' during configuration of proxy factory class. Possible causes are: - The NHibernate.Bytecode provider assembly was not deployed. - The typeName used to initialize the 'proxyfactory.factory_class' property of the session-factory section is not well formed.

Solution:

Confirm that your deployment folder contains one of the following assemblies:

NHibernate.ByteCode.LinFu.dll NHibernate.ByteCode.Castle.dll ---> System.TypeLoadException: Method 'IsProxy' in type 'NHibernate.ByteCode.Castle.ProxyFactoryFactory' from assembly 'NHibernate.ByteCode.Castle, Version=3.0.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' does not have an implementation.

Thoughts anyone?

In response to Vijay Gill’s answer I have decided to take a different tack.

NUGet packages, a one-stop shop, and easy updates!

There is a FluentNHibernate package out there. I have installed it but I guess there is something amiss here too:

Test method CoreDatabaseTests.CreateCoreDatabase threw exception:

System.IO.FileLoadException: Could not load file or assembly 'NHibernate, Version=3.2.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) ---> System.IO.FileLoadException: Could not load file or assembly 'NHibernate, Version=3.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.

fredyfx
  • 403
  • 10
  • 22
k.c.
  • 1,755
  • 1
  • 29
  • 53

2 Answers2

5

With NHibernate 3.2 you don't need NHibernate.ByteCode.Castle anymore, which considerably simplifies your dependency tree.

Mauricio Scheffer
  • 98,863
  • 23
  • 192
  • 275
  • any thoughts on the NuGet packages – k.c. Aug 02 '11 at 14:50
  • 1
    @KSig: if Fluent.NHibernate doesn't currently support NHibernate 3.2, and you need it, help them do it. Don't just stand around waiting for it to happen, *make* it happen. Start in their mailing list: http://groups.google.com/group/fluent-nhibernate – Mauricio Scheffer Aug 02 '11 at 15:15
  • You are right, if not for the dedicated individuals on those projects we would not have (Fluent-)NHibernate at all. Just for putting me straight, I up-voted your answer ;-) – k.c. Aug 03 '11 at 08:55
  • @Mauricio - Note that the new byte code provider has some serious, undocumented incompatibilities with code that used Castle (see http://stackoverflow.com/a/7116710/102554). Just today, I had to add setters to all of my read-only properties that were facades to other objects. Which has cascaded into a whole new set of exceptions. Seriously thinking about reverting to FNH 1.0 / NH 2.1.2, which worked fine. – Tom Bushell Dec 20 '11 at 22:15
  • @TomBushell consider submitting a patch implementing what's missing or fixing the bugs instead. – Mauricio Scheffer Dec 20 '11 at 23:02
  • @MauricioScheffer - I might consider it, but I've just spent far too many hours fixing a nasty automapping bug in Fluent NHibernate 1.3 (submitted as "fix to issue #113" in GitHub today, as a matter of fact), only to be stopped in my tracks by this problem. I'm not highly motivated to dive into yet another large, completely unfamiliar codebase at this exact moment, thank you very much. Sorry if I sound testy, but I'm a little frustrated right now... – Tom Bushell Dec 20 '11 at 23:21
  • @TomBushell : I know what you mean. It's the risk of using complex libraries in your project... – Mauricio Scheffer Dec 21 '11 at 00:11
2

Getting components from various locations in such cases is nto a good idea, you compile everything from scratch. Well that's my experience so far. Fluent NH has not been updated to NH 3.2GA.

I would suggest you to download fluent NH and stick with the version that comes with it OR if you want to be on the bleeding edge, download the sources of fluent NH and compile with references set to latest NH (3.2GA).

Vijay Gill
  • 1,508
  • 1
  • 14
  • 16
  • Amazing, I am sure you could add reference to assemblies compiled for older version of .Net in projects for .Net 4.0. As a proof I have projects which are compiled for 4.0 but have references to assemblies compiled for 1.1 (because we do not have source code for those). – Vijay Gill Aug 02 '11 at 15:01
  • I have reassembled the complete solution and all the projects in it from scratch. Then added the references to the download you mentioned. It seems to be working for now. Thanks! I have marked your answer as correct – k.c. Aug 03 '11 at 08:59
  • Cheers! Glad to be of any help :) – Vijay Gill Aug 03 '11 at 09:01
  • Also see http://stackoverflow.com/questions/5687378/install-nhibernate-3-2-with-nuget. I removed the "proxyfactory.factory_class" from my config and it worked – Andre Jul 28 '13 at 10:27