Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make a C# program be able to compile on any operating system

I have started making a C# program on a XP 32bit windows operating system in c# 2008, and now i am trying to open it in Windows 7 64bit operating system. The problem that arises is that i can't run the program in c# 2010 on my 64bit system and it won't go past the Initialize Component(); line in my code. It comes up with an error of, "BadImageFormatException was unhandled" which i think is because of the system change of where i am opening it. Any help on this we be brilliant.

Thanks

like image 371
Chris Bacon Avatar asked Jan 21 '23 03:01

Chris Bacon


2 Answers

The problem you are faced with is that you have compiled the app with Any CPU. Change it to x86 and recompile.

Most likely you have a library you are dependent on which is x86. Because your app is compiled as Any CPU, the Win7 x64 system is loading it as a 64bit app... and failing when trying to load the 32 bit library.

like image 106
NotMe Avatar answered Feb 07 '23 12:02

NotMe


In Build->Configuration Manager, is your Platform set to "Any CPU" for each project?

like image 29
skaz Avatar answered Feb 07 '23 10:02

skaz