0

I have an odd issue that hopefully someone else has encountered.

  • I have a Unit Test (i.e. TestFileExtract)
  • that calls a method in a class (Test.Expand.Uncompresss)
  • that makes a call to a referenced DLL
  • that makes a call to the ZLIB1.DLL
  • to uncompress a file.

Here is the import :

[DllImport(ZLIB_NAME, CallingConvention = CallingConvention.Cdecl)]

public static extern int uncompress(byte[] dest, ref int dest_len, byte[] src, int src_len);

There is an existing console app that loads the 1st Assembly, calls the method that triggers the uncompress with no issues. However, when I make the exact same call from within my unit test, it fails with BadImageFormatException.

I tried setting the test to x64, x86, auto with no success. I also tried rebuilding the calling assembly to x64/AnyCPU. Same results. I'm sure (hoping) it's something I've overlooked.

Any ideas?

Martin Verjans
  • 4,675
  • 1
  • 21
  • 48
KayGee
  • 1
  • 1
  • MSDN lists the cases when BadImageFormatException may be invoked: https://msdn.microsoft.com/en-us/library/system.badimageformatexception(v=vs.110).aspx Maybe look here also: http://stackoverflow.com/questions/8996653/troubleshooting-badimageformatexception – Jacob Sep 21 '16 at 18:06
  • Thx. I'll take a look to see if any of the SO answers will help. – KayGee Sep 21 '16 at 18:25

0 Answers0