32

I'm new to NHibernate and have been trying to get up and running with it, Fluent NHibernate and NHProf using NuGet. After reading this article (http://gurustop.net/blog/2011/03/13/nhibernate-3-1-0-on-nuget-important-details) it seems that v3.1 shouldn't be directly installed, however, there appears no such warning for v3.2.

After successfully installing NHibernate 3.2 and NHProf using NuGet, I'm unable to install Fluent NHibernate as it says it's "Already referencing a newer version of NHibernate".

Also, when I run my app I get the following error "Could not load file or assembly 'NHibernate.ByteCode.Castle' or one of its dependencies". The following link (Could not load file or assembly in NHibernate) suggests installing a number of additional assemblies, which is what I was hoping to avoid by using NuGet in the first place.

At this point would it just be easier to follow the steps on NHForge to get things up and running as the packages on NuGet don't appear to be compatible?

Community
  • 1
  • 1
RuairiQ
  • 431
  • 1
  • 5
  • 9

5 Answers5

29

NHibernate 3.2 comes with its own proxy factory. If you're using a config file, you just need to remove the proxyfactory configuration property.

I believe the version of Fluent NHibernate that you're using defaults to use NHibernate.ByteCode.Castle. In that case, you would need to override that setting with the built in NHibernate 3.2 proxy factory:

.ProxyFactoryFactory("NHibernate.Bytecode.DefaultProxyFactoryFactory, NHibernate") 
Jim Geurts
  • 20,189
  • 23
  • 95
  • 116
  • 2
    This fixed it for me (or rather, removing the as I am using XML config files). The 'NHibernate.Castle' integration package in Nuget is only up to 3.1.0.4000 at the moment (as I write this comment), they need to update it to the latest version of NHibernate. Hopefully there aren't significant differences between NHibernate's own proxy factory and the Castle one? – James Webster Aug 18 '11 at 05:06
  • 1
    @JamesWebster +1 for removing `` from the XML config. – Joel Purra Apr 05 '12 at 21:55
11

Each version of Fluent NHibernate uses an exact version of NHibernate (included in the Fluent NHibernate package) You should remove the NHibernate package and add only Fluent NHibernate

Catalin DICU
  • 4,610
  • 5
  • 34
  • 47
  • This is correct... don't know why someone down-voted with no comment. – Charlino May 12 '11 at 04:19
  • The Fluent Nhibernate package installs NH 3.1. The question is referencing 3.2. – mxmissile May 18 '11 at 21:21
  • 1
    "I'm new to NHibernate and have been trying to get up and running with it" so I reckon this answer is valid - I'm using 3.1 myself because of these issues, eventually when all the packages catch up we'll all be on 3.2 – Adam May 27 '11 at 07:32
  • 2
    In my opinion, the NH 3.2 package should clearly state that it's a beta version or not be available from NuGet at all. Unfortunately the future of FNH on 3.2 is cloudy: http://lostechies.com/jamesgregory/2011/04/13/me-on-nhibernate-3-2/ – Jamie Ide Jun 28 '11 at 13:00
6

If you use the Nuget Package Manager Console instead of the GUI to get the package (Install-Package FluentNHibernate) you will get version 1.3.0.717 which is compatible with NHibernate 3.2 enter image description here

I tried and is working fine for me. I answered this already on this link: which version of fluent nhibernate is compatible with nhibernate 3.2

Community
  • 1
  • 1
Ajadex
  • 2,319
  • 1
  • 20
  • 23
3

I'm using this consctruction in config file to make FluentNhibernate work with NHibernate 3.2

 <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.2.0.1001" newVersion="3.2.0.1001" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
AlfeG
  • 1,475
  • 4
  • 18
  • 33
0

NHibernate 3.2 comes with its own mapping configuration (Conform). FluentNHibernate only works with NHibernate 3.1 as a result of this, you can't use 3.2 (I had the same problem). So you'll have to manually download 3.1 and reference that unless NuGet allows you to use 3.1 directly.

Your other option is to remove all references to 3.2 and then install FluentNHibernate from NuGet, then the dependency resolver will kick in and automatically include NHibernate 3.1 for you.

Kieran Senior
  • 17,960
  • 26
  • 94
  • 138