NCarlson
NCarlson

Reputation: 340

Why won't Unity recognize this DLL - is it in the wrong place?

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?

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! :)

Upvotes: 4

Views: 7354

Answers (1)

Chuck
Chuck

Reputation: 2102

Ahhh I finally solved the problem! There's a dependency that my DLL requires that doesn't exist. For some reason, instead of giving a dependency error or something like that, Unity is just reporting DllNotFoundException: <dllName.dll>.

I found a GitHub thread suggesting a tool called Dependency Walker to check for dependencies, but that gave me a long list of stuff.

I tried looking around for what Dependency Walker reported and found this answer that suggested an updated (i.e., post-Win7) tool called Dependecies.

THAT tool, when pointed at the DLL that Unity "couldn't find," revealed another common DLL (for my company) that wasn't on my new computer. Tried to find the DLL on the source computer and realized it's installed with the company software the DLL is designed to interface with... big facepalm there. Installed the software, Dependencies found the DLL my Unity one depended on, then Unity "finds" the DLL and runs without issue.

Upvotes: 4

Related Questions