This project is read-only.

System.IO.FileLoadException

May 7, 2012 at 1:28 AM
Edited May 7, 2012 at 1:29 AM

When setting up a class library in VS 2010 for NUnit tests using

NUnit.Framework
NBehave.Spec
NBehave.Spec.NUnit 

and running a test using
    result.ShouldEqual(expectedResult)
I get the following error in NUnit (2.6.0.12051):

"System.IO.FileLoadException : Could not load file or assembly 'nunit.framework, Version=2.5.10.11092, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"

If I set up the test using SetUp and TearDown and
    Assert.AreEqual(result, expectedResult)
instead of using override Because_of and override Establish_context together with 
    result.ShouldEqual(expectedResult) 
I get no errors:

Any suggestions on how to solve this issue are welcome.

Thanks in advance. 

May 7, 2012 at 9:55 PM

Try using nunit 2.5.10 instead of nunit 2.6.0

May 7, 2012 at 9:59 PM
Edited May 7, 2012 at 9:59 PM

I will try that. I managed to make an assembly redirect but it doesn't function as expected. Thanks for your answer.

May 7, 2012 at 10:29 PM

Just installed NUnit 2.5.10 and the assembly redirect is no more needed. But somehow override Because_of and Establish_context doesn't seem to work as expected, but this may be due to my lack of knowledge of NBehave. Now at least the tests run in NUnit. Once again thanks for your answer.

May 7, 2012 at 10:50 PM

Corrected my errors. Everything now works to perfection.

Once again: Thank you for your answer :-)

May 7, 2012 at 10:56 PM

Cool!

Establish_context and Because_of is executed during nunit's [TestFixtureSetup]  and Cleanup during [TestFixtureTeardown].

May 8, 2012 at 2:17 AM

Yeah, I'm getting it :) Thanks!