“An attempt was made to load a program with an incorrect format” even when the platforms are the same

前端 未结 20 2927
悲&欢浪女
悲&欢浪女 2020-11-22 13:57

I\'m calling functions from a 32-bit unmanaged DLL on a 64-bit system. What I get is:

BadImageFormatException: An attempt was made to load a program w

20条回答
  •  日久生厌
    2020-11-22 14:38

    In my case, I was running tests through MSTest and found out that I was deploying both a 32-bit and 64-bit DLL to the test directory. The program was favoring the 64-bit DLL and causing it to fail.

    TL;DR Make sure you only deploy 32-bit DLLs to tests.

提交回复
热议问题