NInject and NHibernate sitting in a tree

.. but not kissing

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 try to resolve the class via NInject, I get the following error:

Could not load file or assembly "NHibernate, Version =, Culture = neutral, PublicKeyToken = aa95f207798dfdb4" or one of its dependencies. The located assembly manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I have the following in my app.config

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


I note that the downloaded NInject package contains the following in the \ packages \ Ninject. \ lib folder

  • .. \ net35-client
  • .. \ net35-Full
  • .. \ net40 client
  • .. \ net40-Full

When I use NuGet to manage packages for a specific library, which of the above is included? Is this a problem that can be solved by manually adding a reference to the correct DLL version of Ninject?



source to share

2 answers

NuGet decides which version is used based on the type of project. For example. you write the .NET Client profile assembly and then add a reference to net40-Client

You can reference any assembly you like manually. But usually NuGet already picks the correct version.



Dropping the link to NH.Linq solved the problem as suggested by Phil



All Articles