1

C# Controller unit tests failing with the below bad image format exception, when referenced to service project. Both the service and unit test project are being built as AnyCpu.

Any suggestions on how to fix this exceptions?

Test method UnitTests.Controller.SomeControllerTests.SampleTest threw exception:

System.BadImageFormatException: Could not load file or assembly SampleService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Nkosi
  • 235,767
  • 35
  • 427
  • 472
SteelBird82
  • 759
  • 3
  • 10
  • 23
  • 3
    Build both as x86. I assume you are on a x64 machine. That exception comes from trying to load x86 native dlls in a x64 program (or vice versa). – Aron May 31 '16 at 03:49
  • 1
    Possible duplicate of [Could not load file or assembly ... An attempt was made to load a program with an incorrect format (System.BadImageFormatException)](http://stackoverflow.com/questions/11370344/could-not-load-file-or-assembly-an-attempt-was-made-to-load-a-program-with-a) – Aron May 31 '16 at 03:49

0 Answers0