Created On:  11 October 2012

Problem:

Customer has Visual COBOL solution that was building fine.  A change was made to one of the compiler directives in the project properties COBOL tab.

Now when attempting to rebuild the solution they get the following error:

Unhandled Exception: Could not load file or assembly
"BadImageFormatException"
attempt was made to load a program with an incorrect format.

Why is this happening now?

Resolution:

This error usually happens if the Platform target type gets changed from Any CPU or x86 to x64 or vice versa.

There is a problem when editing a property page in that if you are not in a particular field and you scroll the mouse it may change the value of the Platform target field.

Check to ensure that the Platform target field is set to the correct type in all of your projects.