17

I just updated my project to use NuGet for external references. I added reference to NHibernate, which added all other dependencies for NH. Than I added FluentNHibernate. Versions of NH downloaded for NH and Fluent do not match. NuGet shows version of FNH as 1.1.1.694 as dependent on NH version 3.0.0.0.2001, while NH is showing as version 3.0.0.4000.

When I run the app, I get this message:

Could not load file or assembly 'NHibernate, Version=3.0.0.2001, 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)

I also tried downloading from FNH site, but that shows that is version on FNH is 1.1.0.685 which is dependent on 2.1.2.4000.

Can you fix the NuGet, or should I just use BindingRedirect in config?

Johnno Nolan
  • 29,228
  • 19
  • 111
  • 160
epitka
  • 17,275
  • 20
  • 88
  • 141
  • Personally I've given up on NuGet, the repositories are all over the place and out of date. – Phill Jan 24 '11 at 09:08
  • @Phil: Really? I just made a switch thinking it would be easier to manage my dependencies – epitka Jan 24 '11 at 16:12
  • 3
    Most packages are up to date. Some don't have official owners quite yet, but this is quickly changing as adoption grows. – David Ebbo Jan 26 '11 at 00:20

1 Answers1

18

You're in luck! NuGet has a command for just this scenario (which we plan to make more automatic in the future http://blog.davidebbo.com/2011/01/nuget-versioning-part-3-unification-via.html). First build your project and from the package manager console type:

PM> Add-BindingRedirect

And it will add the minimal set of binding redirects to config to get everything working.

davidfowl
  • 37,120
  • 7
  • 93
  • 103
  • 1
    The command is actually _Add-BindingRedirects_ in pre-v1.1 versions ... the "s" is missing. – cdeszaq Jan 24 '11 at 14:58
  • @cdeszaq: Will have to try that. For now I just manually added redirect in the config file. Good to know about the option. – epitka Jan 24 '11 at 16:09
  • FYI, the command was plural in 1.0, but changed to singular in 1.1 (to me more PowerShell 'correct'). – David Ebbo Jan 26 '11 at 00:17
  • 4
    I do not like this at all, package managers need to be on this! – mxmissile Jan 31 '11 at 21:15
  • yeah definitely needs to be automatic unless there is some major reason not to. – RodH257 Feb 25 '11 at 04:13
  • Didn't work for me, I had to add the binding redirects manually in my configuration file. – Pawel Krakowiak Jul 02 '11 at 09:04
  • What exact steps don't work for you? What version of NuGet are you running? – davidfowl Jul 02 '11 at 16:56
  • This didn't work for me - ended up downloading downloading the FluentBinaries and importing them manually - shameful that its ended up like this - of over 30 installed packages this is FluentNh is the only one that screwed up like this! – reach4thelasers Feb 04 '12 at 16:45