C# 64 bit: System.BadImageFormatException

Hi,

I just updated to Fmod 1.06 (from fmod 1.05.06), and when running my 64 bit C# app, a System.BadImageFormatException is thrown when trying to intialize the system with FMOD_Studio_System_Create(out rawPtr, VERSION.number). It works fine in 32 bit.

I have both fmod.dll and fmod64.dll in the target working directory.

Is anybody else getting the same problem?

Cheers,
Nick

In your project properties (right click the project in solution explorer and select ‘properties’) and add WIN64 to the ‘conditional compilation settings’ under the ‘build’ tab.

Sorry for the late reply.

I am now using 1.06.01. When compiling the 64 bit version, WIN64 is defined.

On startup of the 64 bit version, it crashes in fmod_studio.cs, line 551 with a System.BadImageFormatException. This is the line of code it crashes on:

result = FMOD_Studio_System_Create(out rawPtr, VERSION.number);

At that location in the code VERSION.number is 67073. VERSION.dll is “fmod64”.

Any ideas?
Cheers,
Nick

I think I found the problem. In fmod_studio.cs there’s the following lines:

public class STUDIO_VERSION
{
    public const string dll    = "fmodstudio.dll";
}

This should be:

public class STUDIO_VERSION
{
#if WIN64
    public const string dll    = "fmodstudio64.dll";
#else
	public const string dll    = "fmodstudio.dll";
#endif
}