0

I have a winforms application that uses nhibernate, nhibernate.validator and other libraries.

When I run the standalone winforms aplication, everything works like a charm.

But when I try to run my test cases using Nunit, it fails to load an assembly:

RManager.Tests.Model.AgentTest (TestFixtureSetUp): SetUp : System.TypeInitializationException : O inicializador de tipo de 'NHibernate.Validator.Event.NHibernateSharedEngineProvider' acionou uma exceção. ----> System.IO.FileLoadException : cannot load file or assembly 'NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' . (Exceção de HRESULT: 0x80131040)

The strange thing is that nhibernate is a dependency on almost everything, but they use version 4.0.0.4000.

Every project has a redirect:

<dependentAssembly>
    <assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.0.4000" newVersion="4.0.0.4000" />
  </dependentAssembly>

How can I figure out what is going wrong? As it appears that the problem is only when running under nunit.

Thank you

bcsanches
  • 2,362
  • 21
  • 32

1 Answers1

-1

Try setting the oldVersion to 3.3.1.4000, this should redirect VS to version 4.0.0.4000

<dependentAssembly>
    <assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
    <bindingRedirect oldVersion="3.3.1.4000" newVersion="4.0.0.4000" />
  </dependentAssembly>
  • Have you looked at this question? http://stackoverflow.com/questions/1560050/could-not-load-file-or-assembly-in-nhibernate?rq=1 –  Jan 27 '15 at 22:08
  • 2
    `3.3.1.4000` is a single version number, that would already be encompassed by the currently specified range (`0.0.0.0-4.0.0.4000`) – Andrew Shepherd Jan 27 '15 at 22:57