0

I'm working on a windows form application that I built to target .net 4.5.2. I then found out my client's machines only run .net 4.0 and they would not be upgrading soon.

I then changed the framework that the application was targeting to 4.0 and got the system.badimageformat exception. This exception would then stay when I changed the framework back to 4.5.2.

So my question is: how do I get my application to run with 4.0 when I cannot change the targeted framework?

  • You changed something else as well. Crystal ball says that you originally had the Project > Properties > Build tab > Prefer 32-bit option turned on. Since that option is not supported in 4.0, it is now turned off and your program can run as a 64-bit process. Which can cause this exception. And switching back to 4.5.2 has no effect, the option is still off. Change the Platform target setting from AnyCPU to x86. – Hans Passant Apr 14 '16 at 17:02
  • The dependencies in the compiler doesn't recognize the change of Net Versions. So deleting the bin folder in the project should allow the code to compile in Net 4.5. I'm not sure why the code failed in Net 4.0. You can try again by deleting the bin folder. Not all code target in Net 4.5 will run in Net 4.0 due to enhancements in Net 4.5 – jdweng Apr 14 '16 at 17:37
  • @HansPassant Thanks for the tip. That did it fix the badimageformat exception. – Andrew Siebert Apr 14 '16 at 18:35

0 Answers0