3

I'm running a C# XNA game project on Microsoft Visual Studio 2013 using a 32-bit architecture. When attempting to load an unmanaged C++ DLL at runtime using the DllImport tag, I get the error below. Note that this dll (fmod_event.dll) comes from the FMOD Ex Programmer’s API located under /fmoddesignerapi/api/

An unhandled exception of type 'System.DllNotFoundException'.
Additional information: Unable to load DLL 'fmod_event': The specified module could not be found.(Exception from HRESULT: 0x8007007E)

The code is has followed and failed during importation.

[DllImport("fmod_event")]
private static extern RESULT FMOD_EventSystem_Create(ref IntPtr eventsystem);

I've added the dll to the root directory of the project and set it to 'Copy if newer'. I can ensure that this dll is present in both the DEBUG and RELEASE bin folders, at the right location.

When importing the 'fmodex.dll' available via the same download file and located under /api/ I don't run into the same issue and everything works as expected with the following code:

[DllImport("fmodex")]
private static extern RESULT FMOD_System_Create(ref IntPtr system);

Both of these dlls can be seen under the same bin folder.
I have tried to use fmod_event.dll 32 and 64 without any luck.

Can anyone provide any insight into why one DLL is loading correctly, but not the other? Thanks

caubry
  • 260
  • 4
  • 13
  • Do _any_ imports work for **fmod_event.dll**? Can you confirm that these two DLLs are located immediately in the **Debug** or **Release** folders? Why do you need to copy them to child folders? –  Apr 04 '16 at 12:23
  • Have you seen this site : http://www.solvusoft.com/en/files/missing-not-found-error/dll/windows/electronic-arts-inc/crysis/fmod-event-dll/ – PaulF Apr 04 '16 at 12:28
  • 1
    I tend not to download DLLs from unknown sources. – caubry Apr 04 '16 at 12:34

2 Answers2

1
  • Specify .DLL as extension
  • Ensure that file exists in PATH, or specify full path in DllImport
  • Check that dependent modules do exist for this DLL. Use Dependency Walker to find if dependent DLLs exists, and are loadable.
  • check 32-bit and 64-bit issue. A process of 32-bit cannot load a 64-bit DLL, and vice versa
Ajay
  • 18,086
  • 12
  • 59
  • 105
  • That's extremely odd, but you fixed it. I indeed HAD to specify .DLL for the fmod_event one. But it seems that the other DLL isn't affected by it. Thanks :) – caubry Apr 04 '16 at 12:33
0

Normally all unmanaged DLLs require registration. If you got fmod_event.dll as not part of installation package try to run regsvr32 on it to register it.

Vlad Setchin
  • 121
  • 1
  • 5
  • That's not true, unless unmanaged/native DLL is COM, and someone is using COM to use it. – Ajay Apr 04 '16 at 12:21
  • Additionally, even if **regsvr32** worked because the module contained a `DllRegisterServer` export that would mean it were a COM server and therefore you don't need to **DllImport** anything. You just use COM. Rarely does a module contain a bunch of exports in addition to being a COM server –  Apr 04 '16 at 12:30