How to debug System.BadImageFormatException An attempt was made to load a program with an incorrect format?


I'm attempting to include a C++ lib/dll into a C# project using a CLI wrapper, but After I added to the C# project references I started to get the following:

System.BadImageFormatException occurred
  Message=Could not load file or assembly 'Wrapper, Version=1.0.7558.26276, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
  Source=<Cannot evaluate the exception source>
   <points to main()>

I've seen a number of similar questions asked, but they all seemed to be focused on 32/64 bit mismatch. My C++ lib, CLI Wrapper and C# project are all set to 64bit, so I don't think it is the same problem.

But in general, how would I go about trying to investigate the reason for this type of error, is there a way to et more details somehow? Check versions of something?

asked on Stack Overflow Sep 14, 2020 by Maxim

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0