Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unity not finding DLL dependency of another DLL (both in Assets folder)

Background info (might be relevant):

  • Using Unity 2017.2 with "Scripting Runtime Version" set to "Experimental (.NET 4.6 equivalent)"
  • Writing code in Visual Studio 2017 (not MonoDevelop)

I have a Unity project that makes direct use of a third-party DLL ("library A"), which I've added to the project's Assets folder. Library A depends on another DLL, "library B", which I've also added to the Assets folder. Library B is not used by any scripts in the Unity project. Both libraries A and B are written in C# and target .NET 4, i.e., they're both managed code.

Once added to the Assets folder, both libraries A and B are listed under "References" when the project is opened in Visual Studio and "Copy Local" is set to "True" for both (although I don't know if Unity uses that property).

However, when running the project in the Unity editor, various calls to library A raise exceptions that indicate that library B isn't available. The only way I've been able to get it to work is by placing a copy of library B in C:\Program Files\Unity\Editor (the directory containing Unity.exe, the Unity editor executable).

I've used libraries A and B in other, non-Unity projects and never had any issues (Visual Studio copies them both to the output directory as long as they're referenced). Am I missing a Unity-specific step that's necessary to tell it that library B is required?

like image 860
Reign of Error Avatar asked Jun 21 '18 15:06

Reign of Error


1 Answers

I ran into this same issue today, and here's what fixed it for me: In the Unity editor, navigate to where the library B is located, select the library, and on the Inspector window under "Plugin load settings", enable the "Load on startup" checkbox. I suppose this is needed because no Unity scripts are directly calling library B.

like image 195
Bob Avatar answered Sep 16 '22 15:09

Bob