Search code examples
c#dllimport32bit-64bitbass

BadImageFormatException on bass.dll


One year ago I was using bass.dll on a mp3 project. Back then I was using Windows 7, 32bit. Now I am on another project and I need to use the bass.dll again. This time I am on Windows 8.1, 64bit.

Bass_Start() is giving me this exception as well as all the other functions

An unhandled exception of type 'System.BadImageFormatException' occurred in EZBlocker.exe

Additional information: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B).

I am using DllImport to import those functions and the bass.dll in in my project.

[DllImport("bass.dll")]
public static extern bool BASS_Start();

try
            {
                BASS_Start();
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

What am I missing here besides these thousands of bugs these 64bits windows are giving me? It is my first time on 64bit and I really regretting it...


Solution

  • If you are building your project on x86 only then you will need to use the same version of bass dll. You could always use the Bass.Net dll. You can include it in your project and call all the functions from the bass.dll from there.