Friday, March 27, 2009

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

I'm updating here until I resolve what I'm going to do withgodpatterns.

Recently I setup a new dev machine, while I'm back in the UK searching for a new job (I'm hoping to get something to do with C# if possible). Anyway I moved my SVN repository over along with my most recent code check outs.

As I mentioned in my last post I'm developing using C# and Tao (which, among other things, is an OpenGL wrapper).

On running my code I got a runtime crash. An exception


public SoundManager()
{
Alut.alutInit();


When the program tries to start up OpenAL I get the error message "An attempt was made to load a program with an incorrect format."

It's worth noting I'm now developing on Vista (this machine had it preinstalled) and the machine is 64 bit. Using this post, I found out the problem is that the Tao dlls are x86 (32 bit) and I was trying to compile my code as 64 bit. This seemed to be default in visual studio.

If you want to fix this, then for each project in your solution go to Project > Properties. This will bring up a dialog. Select BUILD, then find the combo box next to the label 'Platform Target'. Change this from any to x86.

That should fix any problems.

(One other issue I seem to be having is a number of dlls are missing in Vista. So for now I'm just including copies with my executable)

Happy hacking.

Note: If you're still having problems and want some more voodoo. I also remove all my Tao references and readded them

3 comments:

Denis Mouraux said...

Thanks, I had the same problem with a C# tool that wouldn't run on Vista 64 and I found this post -- you just saved me a lot of time :-)

Unknown said...

You saved my time. A colleague changed the platform in a referenced project. Thank you.

Unknown said...

Thank you. A colleague changed the platform in a referenced project.