I know that this question has been asked a lot but none of the solutions have worked for me so far. I am trying to build a project using a third party dll. I am using VS2015 and targeting .NET 4.5.2 framework. I have set the solution platform to AnyCPU and platform target for the project to AnyCPU as well. I get the following exception when I run the project "An unhandled exception of type System.BadImageFormatException
occurred in mscorlib.dll
Additional information: Could not load file or assembly XXX, Version=1.0.5842.29961, Culture=neutral, PublicKeyToken=null
or one of its dependencies. An attempt was made to load a program with an incorrect format."
I have tried to figure out the headers of the dll using corflags and following are the results
Version : v4.0.30319
CLR Header : 2.5
PE : PE32
CorFlags : 0x10
ILONLY : 0
32BITREQ : 0
32BITFREQ : 0
Signed : 0
As per this answer i should be setting platform targets to AnyCpu which is I am doing, but still can't get it to work.