Jkh2
Jkh2

Reputation: 1030

C# application throwing system.BadImageFormat exception. Dependencies compiled in x64

I have been trying to run the first skeleton program listed here: https://sites.google.com/site/augmentedrealitytestingsite/download

I am using VS2010 express under Windows 7 64bit.

When I tried to build and run, it first threw:

"An attempt was made to load a program with an incorrect format"

Followed shortly by a System.BadImageFormatException due to calling a PInvoke method from the referenced ARTKPManagedWrapper.DLL.

I recompiled the reference on my PC but the problem persisted. I also tried to set the target platform to x86 (it is currently set on Any CPU) but there was no option other than Any CPU.

Does anyone have any idea what else could be going wrong here?

Upvotes: 0

Views: 175

Answers (2)

Mark Hall
Mark Hall

Reputation: 54532

You have to create the option if it isn't there. I was able to get it to work by going into Build --> Configuration Mananger going into the Platform Column and creating an new x86 configuration.


If configuration manager is not visible to you. You will want to look at this Blog

From Blog:

First, select Tools|Options to bring up the Options dialog. Make sure that "Show all Settings" in the bottom left-hand corner is set. Select the Projects and Solutions page and set "Show Advanced build configurations."

and from the Comments

You've just got to ensure that Tools -> Settings -> Expert Settings is selected as well.

Upvotes: 1

SCB
SCB

Reputation: 3084

In IIS on the app pool for the website under the advanced settings change the following setting

Enable 32 bit applications to true.

enter image description here

Upvotes: 0

Related Questions