0
votes

I try to make some unit tests with NUnit for a simple NHibernate Mapping, with an InMemory SqLite Database. The SqLite is referenced in my Unit Test Project and NHibernate is referenced by both projects in the same version by Nuget.

My Test looks like

[Test]
    public void AddDocumentTest()
    {
        var document = new Repository<Document>(Session);
        document.Add(new Document { FileName = "Blubb", Id = Guid.NewGuid(), Title = "Dummy Title" });
        // here comes the error            
        var i = document.All().Count();
    }

When I call some Linq Methods on the document class I get

System.IO.FileLoadException : Die Datei oder Assembly "NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4" oder eine Abhängigkeit davon wurde nicht gefunden. Die gefundene Manifestdefinition der Assembly stimmt nicht mit dem Assemblyverweis überein. (Ausnahme von HRESULT: 0x80131040)

Sorry I have this only in german but I think its clear what happens. Why does he look for a complete different Version of NHibernate? (my version is 3.3.1.4000)

1
Not sure if it will help, but here is an answer to a FileLoadException question where two assemblies with different version numbers are configured to work together.Anders Gustafsson
Thanks, I found the problem now.Sebastian

1 Answers

0
votes

The problem was that I have also a reference to the NHibernate2Linq project which tries to get Nhibernate in an old version.