Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NInject and NHibernate, sitting in a tree

.. but not k.i.s.s.i.n.g

I am trying to use NInject with NHibernate. Through NuGet I am using

  • NHibernate v3.1.0.4000
  • NHibernate.Castle v3.1.0.4000
  • NHibernate.Linq v1.0
  • FluentNHibernate v1.2..0.712
  • NInject v2.2.1.4

When I attempt to resolve a class through NInject I get the following error :

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

I have the following in app.config

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" />
    <bindingRedirect oldVersion="2.1.0.4000-2.1.2.4000" newVersion="3.1.0.4000" />
  </dependentAssembly>
</assemblyBinding>

I note that the downloaded NInject package contains the following under \packages\Ninject.2.2.1.4\lib

  • ..\net35-Client
  • ..\net35-Full
  • ..\net40-Client
  • ..\net40-Full

When I use NuGet to manage packages for a particular library which of the above versions is being included? Is this a problem that can be resolved by manually adding a reference to the correct Ninject dll?

TIA

like image 363
Alan Alcock Avatar asked Dec 05 '25 09:12

Alan Alcock


2 Answers

NuGet decides which version is used depending on the project type. E.g. is you are writing a .NET Client profile assembly then it will add a reference to net40-Client

You can reference any assembly you like manually. But normally NuGet already chooses the correct version.

like image 186
Remo Gloor Avatar answered Dec 08 '25 08:12

Remo Gloor


Dropping the reference to NH.Linq resolved the problem as Phill suggested

like image 45
Alan Alcock Avatar answered Dec 08 '25 06:12

Alan Alcock



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!