# C# 64 bit: System.BadImageFormatException

**URL:** <https://qa.fmod.com/t/c-64-bit-system-badimageformatexception/11880>\
**Category:** FMOD Engine\
**Created:** [April 11, 2015, 12:07am UTC](https://qa.fmod.com/t/c-64-bit-system-badimageformatexception/11880 "2015-04-11T00:07:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![NickWaanders](https://avatars.discourse-cdn.com/v4/letter/n/ee59a6/32.png) [@NickWaanders](https://qa.fmod.com/u/NickWaanders)\
**Post date:** [April 11, 2015, 12:07am UTC](https://qa.fmod.com/t/c-64-bit-system-badimageformatexception/11880/1 "2015-04-11T00:07:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nick1](https://avatars.discourse-cdn.com/v4/letter/n/47e85d/32.png) [@nick1](https://qa.fmod.com/u/nick1)\
**Post date:** [April 13, 2015, 12:46am UTC](https://qa.fmod.com/t/c-64-bit-system-badimageformatexception/11880/2 "2015-04-13T00:46:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![NickWaanders](https://avatars.discourse-cdn.com/v4/letter/n/ee59a6/32.png) [@NickWaanders](https://qa.fmod.com/u/NickWaanders)\
**Post date:** [April 25, 2015, 12:56am UTC](https://qa.fmod.com/t/c-64-bit-system-badimageformatexception/11880/3 "2015-04-25T00:56:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![NickWaanders](https://avatars.discourse-cdn.com/v4/letter/n/ee59a6/32.png) [@NickWaanders](https://qa.fmod.com/u/NickWaanders)\
**Post date:** [April 25, 2015, 6:42pm UTC](https://qa.fmod.com/t/c-64-bit-system-badimageformatexception/11880/4 "2015-04-25T18:42:04Z")

</div>

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
}
```
