FMOD C# Wrapper unable to find fmod.dll (from Monogame 3.8) - c#

I'm attempting to bring FMOD Core 2.02 into my Monogame 3.8 project using the dll's and C# wrappers (which appear to be auto-generated from the C++). I've set the .dll's to Copy to the output directory on build, and I'm accessing them like so:
[DllImport("kernel32.dll")]
public static extern IntPtr LoadLibrary(string path);
public void OnSystemLoad()
{
if (Environment.Is64BitProcess)
LoadLibrary(System.IO.Path.GetFullPath("FMOD\\x64\\fmod.dll"));
else
LoadLibrary(System.IO.Path.GetFullPath("FMOD\\x86\\fmod.dll"));
}
Everything's working just fine up to this point, the .dll's accessible from the pointer. However, once I go to create a new FMOD System using:
FMOD.Factory.System_Create(out FMODSystem);
I get this error in a popup window:
The procedure entry point ?setFadePointRamp#ChannelControl#FMOD##QEAA?AW4FMOD_RESULT##_KM#Z could not be located in the dynamic link library ...fmod.dll.
Followed by this error on the auto generated C# code itself:
System.DllNotFoundException: 'Unable to load DLL 'fmod' or one of its dependencies: The specified module could not be found. (0x8007007E)'
I'm confidant that the .dll is being found just fine, because if I intentionally mess with the Path to something incorrect then the first error never appears.
Has anybody successfully integrated FMOD with Monogame in 2021? If so, please advise, would love any guidance on getting this up and running... don't want to be stuck with Monogame's MediaPlayer!
Other resources I've found on this subject (none of which have worked for me so far):
https://mysteriousspace.com/2015/05/31/fmod-in-c-its-a-pain-to-set-up-heres-how-i-did-it/
https://github.com/Martenfur/ChaiFoxes.FMODAudio

Managed to solve this by reverting to an older release of FMOD, version 2.01.
I'll write a ticket to let the FMOD team know, but my hopes aren't high, since they don't seem to care much for C# beyond Unity.

Related

Unable to load DLL: The specified module could not be found

I am getting what seems to be a common issue in my C# program.
I have been looking online in many places and tring different solutions. ALl of whihc have so far failed.
I came across this post and tried their solution which did not work:
Unable to load DLL The specified module could not be found
I downloaded dependancy walked to see if I was missing any other dlls which, it is reporting that I am but those dlls are the win-API dlls. Which according this link: https://social.msdn.microsoft.com/Forums/en-US/a28331ae-19a3-4a34-b3ba-1e8fd4430375/missing-apimswincore-dlls, it doesn't matter if dependency walker reports those as missing.
I have also downloaded and installed the VC++ redistribute 2015 x64 and x86 and I am still recieving the same error.
There was another post that recommended that I install the windows SDK. I did this for windows 10 and again, still the same error.(Missing dlls on 64 bit Win).
I have even tried placing the dll in system32 folder but again, no issue
I am running out of ideas on how to solve it so if anyone else ran into the same issue, any help would be appreciated.
For those wondering, I am developing on win 10 using VS2015.
EDIT:
The name of the DLL that I am using is called: SLABHIDtoUART.dll
My code for importing the functions is a as follows:
[DllImport("SLABHIDtoUART.dll")]
public static extern int HidUart_GetNumDevices(ref uint numDevices, ushort vid, ushort pid);
Here is the exact error:
System.DLLNotFoundException: Unable to load DLL 'SLABHIDtoUART.dll': The specified module could not be found (Exception from HRESULT: 0x8007007E)
Oh and I did change the compiler settings in VS from Any CPU to x86. Technically, I did not have that as an option by default and I needed to add a new option for the x86. After a recompile with the x86 compiler, the program still doesn't seem to be working.
I even moved all of the DLLs that the SLAB dll depends on and ran the program and the program still did not run. (SLAB dll depend on hid.dll, setupapi.dll, and kernal32.dll)
I apologize for not posting an update to this question!
I eventually figured out the issue. It would appear the I was using a 64-bit version of the dll for a 32-bit application. Once I loaded in the 32-bit version of the dll, I was able to compile without any issue!

DLLNotFoundException under Unity whilst using FUBI

I'm currently working on my Bachelor-Thesis, which revolves around extending the functions of a Kinectv2 in an Unity-environment.
However, I have little-to-no experience with Unity and C# and whilst setting up the FUBI library (which will be a core of my Thesis), I ran into this problem right away:
Upon starting the Unity project (provided by FUBI), I get a
DLLNotFoundException: FUBI.64.dll
followed by a plethora of errors from failing calls on said library.
The confusing part, to me: Back in university we decided to use FUBI, because we managed to install it, outofthebox, with zero issues within a few minutes. But now, at my home tower (Windows 10 and Unity 5.3.5, just like the machine at the university), this error persists.
The Unity project and all required DLL's are provided in a single download from the FUBI-website itself, which implies that the error shouldn't lay in the project, the provided DLL's or any weird dependancys.
The only thing one has to do (according to FUBI's readme) besides unpacking the zip containing the project is:
IMPORTANT: After installing the Kinect SDK, please execute the "CopyFaceTrackRedist.bat" located in the FubiUnity base folder or manually copy the "Kinect20.Face.dll" and "NuiDatabase" from the Kinect Developer Toolkit to that folder.
Which I've done via the bat, executed flawlessy and had both mentioned files/folders copied into the project directory.
Whilst trying to fix this, I started manually moving the Fubi64.dll to various locations within the Unity project, but the only result was Unity mentioning it found multiple instances of said dll, would only use one, and then throw the exception nontheless.
I've started to think it may be a dependency thing, but downloading and using the dependencywalker gave me little to no useable results.
(I mean, it's showing some errors, but afaik those are related to DW not being updated and unable to work with some forward-dependency-shenanigans or something, according to some other thread on stackflow I've read.)
Any help, or even pointers at what to try next, would be appreciated.
Spending days chasing after the issue, I finally found one entry in dependencywalker that made sense and after manually installing MPFLAT.dll into windows\system32, Unity was able to load the dll just fine. I would assume it's some dll related to mediaviewer or associated tools, since those don't come natively with Win10, I didn't specifically install any yet and it is well possible the other mentioned tower had something installed that brought the DLL along.

Import and use C++ DLL functions in C# application

I am developing an application that communicates with some hardware using the C++ DLL provided by the hardware provider. I also have a header file for this DLL, but no source file. In my C# application, I'm trying to import and call the DLL's functions like this:
public class MyClass
{
[DllImport("CaGe.dll")]
public static extern long someLibraryFunction();
public void callLibFunction()
{
Console.WriteLine("function call: " + someLibraryFunction());
}
}
The library.dll file is located in the same folder as the MyClass.cs file and also the rest of the project files. When I start the debugging session however, I first receive a dialog window from system saying: CAGE InitDll: Erro on load library "CdbClientInit" and after I click OK on that, an unhalted exception on the line where I call the library function occours.
The exception says: System.DllNotFoundException: Exception from HRESULT: 0x8007045A
I found on the internet that this may be caused by a missing DLL that the CaGe.dll needs, so I tried to put the DLL through the Dependency Walker, but the results are a little bit confusing for me. Under the CAGE.DLL there are WS32_32.DLL, VERSION.DLL, KERNEL.DLL and USER32.DLL tabs, I susspect that the libraries I need are somwhere under the USER32.DLL tab, but I don't recognize any of them (if a missing DLL is what is causing this problem).
Any advice would be much appretiated :)
More help to use C++ function in C# please check below URL
http://www.codeproject.com/Questions/107152/Using-a-C-dll-in-a-C-application

Using DllImport to load unmanaged dll into managed application

In my project I have an unmanaged native C++ dll and a C# application. I am trying to import a function from the unmanaged dll using DllImport but I keep getting a DllNotFoundException.
Here is my code that calls the DLL.
using System.Runtime.InteropServices;
namespace TestApp
{
public delegate void UpdateDelegate(string s);
class Program
{
[DllImport("CGPUnmanagedLibrary.dll")]
internal static extern int parse_raw_gsod_file(
[MarshalAs(UnmanagedType.LPStr)]
string filePath,
int minTemp,
UpdateDelegate callBack);
static void Main(string[] args)
{
UpdateDelegate myCallBack = new UpdateDelegate(Program.Report);
string path = #"C:\Creative Solutions\Projects\Clyde's Garden Planner\Frost Data Database\GSOD Data\GSOD_RAW_DATA\1992\gsod_1992.txt";
int result = parse_raw_gsod_file(path, 32, myCallBack);
Console.Write("Parse completed with exit code: " + result.ToString());
Console.ReadLine();
} // end main function
public static void Report(string msg)
{
Console.Write("Message is ");
Console.WriteLine(msg);
}
} // End class
} // end namespace
I tried copying the DLL to the app output directory but it still can't find it. I also tried adding the DLL project as a reference but I get a popup window saying it can't be added. How do you properly link an unmanged DLL to a managed application?
Update - Here is the full error:
Unable to load DLL 'CGPUnmanagedLibrary': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Update 2 - I know for sure that the DLL is in the same directory as the .exe trying to load it. This makes me think there is a dependency in the DLL that isn't getting loaded. I'm only using basic C++ libraries in the DLL (string, math, iostream, etc). Any ideas what could not be loading and why?
Update 3 - Tested with Dependency Walker
Loading my unmanaged C++ DLL in dependency walker showed no errors. I also tried to open my executable in dependency walker and it showed errors loading two DLLs: GPSVC.DLL and IESHIMS.DLL - doesn't make any sense because I am only using standard c++ libraries in my code. I think it may have something to do with the fact that I have a managed C++/CLI DLL trying to load the unmanaged DLL as well (I was trying to implement some C++/CLI wrappers). Anyway, I have since started a new VS solution and moved on. See my answer.
In all likelihood the problem isn't the DLL you're trying to load but one of its (chained) dependencies. Run depends.exe or a similar utility on the DLL to see if all the dependencies can be found. The misleading message "The specified module could not be found" has become a classic annoyance (if not FAQ material!): it leads you to think that your DLL is not being found when almost all of the time it's one of its dependencies that's not being found.
To test, the *.dll needs to be in the same directory as the .exe that is trying to load it. Don't trust Visual Studio to do it for you at this point. Physically copy the file to C:******\Debug\x86\bin\ or whichever configuration you are running under. If in doubt, copy it to all of your bin folders. After you figure out the path, then you start finding ways to automate the project build to copy the file correctly. If that doesn't do it, put it in system32--it will certainly find it there. However, if after doing these things, you still can't find it. There is probably a dependency to your unmanaged dll that is also missing.
First I want to thank everyone for their help. Unfortunately I never did solve this issue (see edits in my main question). The answer turned out to be starting a totally new Visual Studio solution and creating two new projects: C# app and C++ dll. I did away with the need for wrappers as I am now just marshaling two main functions.
Thanks again.
The anwer of user arayq2 made much sense and I was quickly able to solve my problem also.
The dll that couldn't be loaded (DllNotFoundException) in my case is depending upon another dll. This dll (that is not part of my project) was actually compiled with newer versions of certain .h and .lib files. Older versions of these .h and .lib files (with the same filename) were part of the project that compiled the dll that couldn't be loaded.
After I updated my dll project with the newer versions of these .h and .lib files and recompiling my dll project, my problem was solved.
Thank you arayq2!

Unable to load DLL 'UNRAR.DLL': The specified module could not be found

I just downloaded UnRAR.dll from http://www.rarlab.com/rar_add.htm package includes C# sample project when I run in VS 2010 after selecting .rar file for extract I am getting below error message
and when I add reference unrar.dll I am getting below error
Please help / point me what I am missing?
UnRAR.dll is not a .NET assembly so it cannot be used as a project reference.
It is a native DLL so you'll have to use P/Invoke to access its methods or write a C++/CLI wrapper around it.
There's some sample code in this MSDN forum thread that should provide a decent starting place and show the necessary approach.
There also appears to be a fairly complete wrapper included in the Blue Mirror CD/DVD Indexer project.
It should also be noted the SevenZipSharp includes support for this out-of-the-box. I haven't used it myself, but it might be worth checking into.
The sample you are talking about use
[DllImport("unrar.dll")]
to access the functions inside the library.
This DLL should be visible when the test project runs.
So you should copy it into the BIN\DEBUG folder or in a
folder where your project runs.

Categories

Resources