[C#] Unable to load DLL 'fmodstudio64.dll'

I am currently trying to get FMOD integrated into our C# game project (not Unity) but running into some issues. It was relatively simple getting things added in and compiling, but during runtime I always get an error about loading fmodstudio64.dll. I even tried hardcoding the absolute path of the file as a test, but it still failed when attempting to load despite the fact that it was pointing directly at the proper DLL file.

I’m using Visual Studio 2017 Community Edition, and my solution is set up as follows:
FMODWrapper.csproj - Just a simple class library project which includes all the cs files from the FMOD studio and lowlevel include directories. It has WIN64 set in the project to ensure we’re using 64 bit dll files.
Engine.csproj - Includes references to the FMODWrapper project and several MonoGame projects that make up the core engine of our game. This is also a class library project.
Game.csproj - This is the startup project and actual application project used to run the game via Visual Studio. Contains a reference to Engine project and has the main loop of the program.

I have an AudioWrapper.cs file in my Engine project which wraps the FMOD functionality and currently all I’m attempting to do is initialize it. The init function is as simple as:

public void Initialize()
{
FMOD.RESULT result = FMOD.Studio.System.create( out system );
Debug.Assert( result == FMOD.RESULT.OK );

system.initialize( 2, FMOD.Studio.INITFLAGS.NORMAL, FMOD.INITFLAGS.NORMAL, IntPtr.Zero );
}

And “system” is defined as a private class member FMOD.Studio.System.

If anyone has any advice, it would be extremely helpful. I’m not sure what the issue is because, as I mentioned, I even tried hardcoding the STUDIO_VERSION.dll string in fmod_studio.cs to an absolute path of where the dll is located and it still failed. I’ve seen similar topics about failing to load this file, but the solutions are generally just making sure the dll is in the same directory as the executable, which does not seem to be the issue here.

Found the solution - looks like C# just has terrible error messaging when it comes to a failed LoadLibrary call. The actual error was that it was failing to load fmod64.dll, which fmodstudio64.dll is dependent upon. I fixed the issue there (was just a stupid error in my copy to output directory logic) and things seem to be working correctly now.

1 Like