4

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

Chris Bacon
  • 995
  • 8
  • 30
  • 42

3 Answers3

8

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.

NotMe
  • 87,343
  • 27
  • 171
  • 245
  • I go to this but it gives me only one option of "AnyCPU" so i can't change it to any other like "x86"? – Chris Bacon Nov 08 '10 at 18:38
  • @Chris, look at "Platform target" rather than at "Platform". In VS2008, the former gives you multiple options, but not the latter. – HTTP 410 Nov 08 '10 at 18:50
  • 1
    @RoadWarrior: Although, one should note that Debug and Release store these separately, so you'll likely want to change both. – Powerlord Nov 08 '10 at 18:55
1

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

skaz
  • 21,962
  • 20
  • 69
  • 98
0

What is your build profile set to AnyCPU, x86, or x64 there is of course compiling the program on the new machine.

I assume you have all the updates to .NET and Visual Studio on each computer, correct?

Security Hound
  • 2,577
  • 3
  • 25
  • 42
  • I think i set it to AnyCPU, also i am on my laptop at home, windows 7 64bit, and can't get to the 32bit xp computer, so need to change it on my windows 7 64bit system using c# 2010 – Chris Bacon Nov 08 '10 at 18:26
  • You should be able to recompile the project. Some additional information: http://dobrzanski.net/2010/06/29/attempt-load-program-incorrect-format-exception-hresult-0x8007000b/ this was posted by http://stackoverflow.com/users/118896/jaroslaw-dobrzanski – Security Hound Nov 08 '10 at 19:23