4

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

NCarlson
  • 330
  • 2
  • 13
  • 2
    "Plugins failed to load . . . because one or more of its dependencies could not be loaded." probably means Unity is finding the dll you added, but is missing something additional that that dll wants. (See https://stackoverflow.com/a/7378982/342842) – Immersive Dec 09 '20 at 00:32
  • Thank you! I have a feeling this is the issue, but I have no other documentation. How can I debug this further to identify what exactly is missing? – NCarlson Dec 09 '20 at 14:28
  • I just read through the link - I have a few things to try and then I'll update. Thank you Immersive! – NCarlson Dec 09 '20 at 14:35
  • 1
    @NCarlson - Any update? – Chuck Jan 08 '21 at 14:59
  • @Chuck Unfortunately no, this project is on a short deadline, so I opted to basically scrap the dll for now and write my own workaround entirely. In the future I want to try to rebuild the dll using a different PC with different versions of the dependencies, and see if I can get Unity to recognize it. – NCarlson Jan 08 '21 at 15:02
  • I'm still open to more suggestions on what to try. I've basically pulled the entire Unity project apart, putting the dll and dependencies in different folders. Still no luck. – NCarlson Jan 08 '21 at 15:03

1 Answers1

4

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.

Chuck
  • 1,977
  • 1
  • 17
  • 23
  • 1
    I had a brief issue in the interim where the DLL wasn't actually correct for the version of the program I had installed - "[DLL Hell](https://en.wikipedia.org/wiki/DLL_Hell#Incompatible_versions)." Dependencies made it look like I was missing some VC Redistributables or something, even though those were all installed. Once I installed *the appropriate version* of the software to go with the DLL, everything worked. – Chuck Jan 11 '21 at 13:54