0

I am getting following exception at runtime when I changed platform from AnyCpu to x64 of a web application. I am running it locally on windows 7 x-64

[BadImageFormatException: Could not load file or assembly or one of its dependencies. An attempt was made to load a program with an incorrect format.]

MPelletier
  • 16,256
  • 15
  • 86
  • 137
Elvin
  • 2,131
  • 8
  • 23
  • 25

3 Answers3

2

As well as checking whether you have any 32-bit components you should also check whether the ApplicationPool that's running your app is set to run as 32-bit. From IIS Manager > Application Pools > Your App Pool > Advanced Settings > Enable 32-Bit Applications. This should be set to False if you want to run in 64-bit mode or True if you want to run in 32-bit mode.

Rory
  • 40,559
  • 52
  • 175
  • 261
1

Sounds like you have a component/DLL that is 32-bit, while you are trying to force the Web Application to run solely as a 64-bit application.

You may also consider looking at: Read

Community
  • 1
  • 1
Dane Balia
  • 5,271
  • 5
  • 32
  • 57
0

If you leave it as anycpu and it's compiled on a 64 bit system, it should compile and run on 32 and 64 bit. Don't try specifying an architecture when compiling unless you want it to be only 32bit specifically.

Ensure you have the 64bit framework installed.

Delorean
  • 491
  • 4
  • 17