Unity won't recognize DLL

I have inherited a project that has little to no documentation. Basically its a Unity project that receives simulated heart rate information from a running Linux program, to display.

I was given a working version of the Unity application running on a tablet. But when I open the project from the repository, and try to run it, I get a DllNotFoundException. I’m still trying to figure out exactly how this whole project was set up, but as far as I understand, the DLL was written to convert C++ to C# for use with Unity, so the source folder includes a C# interface class, as well as .cpp and .h files.

This DLL is one of several in the project, but its the only one that is throwing the error. At first I thought this could be a bad DLL, so I followed the few instructions I had to generate new ones, and those generated dlls didn’t work either. The previous Dev used CMake to create the dlls for the working version. I have tried using cMake as well as Visual Studio, to generate the dlls, and still get the same exception.

Then I thought it could be related to the .net Framework version used to generate the C# interface, but a debug call the previous dev included shows that the c# interface (called Iface) is loaded. I also re-generated the dlls through visual studio (community 2019) with .Net framework 3.5, and still I get the same result : DLLNotFoundException

I also tried changing the Unity build settings to target the different platforms the previous developer said it worked with, PC, Android, and Universal Windows. I get the same DLLNotFoundException no matter which platform is targeted.

I’m not sure if this is related or not, but I found that if I check “Load on Startup” in Unity under the “Plugin Load Settings” I get the error “Plugins failed to load . . . because one or more of its dependencies could not be loaded.” I’ve been trying to figure out exactly which dependencies aren’t being loaded.

I have the plugins in the folders the previous developer instructed, in Assets>HeartRateEngine>Plugins and then that plugins folder has Native and Managed folders, the one throwing the exception is in the Native folder. I thought the location of the DLL may be part of the problem?

Is this a known issue? How can I debug this issue further?

I’m going to try re-cloning the entire project, and regenerate all the dlls again, but I’d love any assistance. I can update with code if necessary, but I currently don’t think code is the issue since the previous developer was able to get it working, and I have access to the history. I’ll update soon if I make any progress. I apologize if this is a poorly written question, I’m just getting desperate. Thank you so much for reading all this! :slight_smile:

First get familiar with native code interoperation. There are some good summary pages on it in the Unity docs. The terminology Unity uses for this is a “native plugin.”

I don’t know how old your example program is, but native interop on Unity has come a long way, to the point that if you are building with IL2CPP (required now for iOS and Android), you don’t even need to make a DLL out of native code: you can just place a .C file into your Plugins directory and call the code inside directly.

But again, work through the Unity docs on it. Each platform has its own fiddly finicky rules. Get a simple “add two integers together” native function in C working first, and get it going on all your target platforms, THEN look into the DLL issues, which may have gone away by that point once you understand how to link to native stuff.