views:

64

answers:

1

I have a VS solution with many assemblies and third-party utilities. I need to force the app to run 32-bit when running on a 64-bit machine. The app runs just fine on a 32-bit machine. I forced the .exe file to be ILONLY 32BITREQUIRED and when run on the 64-bit machine, I am getting "an attempt was made to load a program with an incorrect format" error. It was my understanding that changing the exe would force all the assemblies to load as 32-bit. What is going on?

+1  A: 

I know this is an old question; maybe you already found your answer.

I'm not familiar with setting ILONLY and 32BITREQUIRED... usually choosing x86 instead of ANYCPU in the compiler drop-down box before compiling takes care of everything you need. You can verify that all your apps are set to compile to x86 in the configuration manager, as well.

Most likely, what you're running into is that one of your third-party utilities installed a 64-bit DLL on the 64-bit machine, and your forced-32-bit application is trying to load a 64-bit DLL. If a third-party DLL has a 32-bit and 64-bit version, chances are the installer is smart enough to know which one to lay down.

Two places you can go on the 64-bit machine to check:

  1. If the program installed to C:\Program Files\, it's a 64-bit DLL; otherwise it would have been installed to C:\Program Files (x86)\
  2. Navigate to the GAC from the command line: c:\Windows\assembly and look under GAC_32 vs. GAC_64. If you find it under GAC_64, you're trying to load the 64-bit DLL

HTH! James

James B