Can only load sqlite3.dll after Toggling and Applying "Exclude Editor" setting twice

Context

  • My project targets Windows standalone. My 2021.3.27f Unity install has the Android and Windows modules.
  • I call the following in Awake for a script:
var lvn = SQLite.SQLite3.LibVersionNumber();
Debug.Log("Lvn: " + lvn);
  • After hitting Play in the Editor, I am getting “DllNotFoundException: sqlite3.dll” exceptions despite having a file named “sqlite3.dll” in my 2021.3.27f1 Unity project’s Plugins folder.
  • I have copied SQLite.cs from here (sqlite-net/src/SQLite.cs at master · praeclarum/sqlite-net (github.com)). This file will eventually call something like [DllImport(LibraryPath...)] where LibraryPath is just sqlite3
  • I got sqlite3.dll from the Windows x64 precompiled binaries here: SQLite Download Page. I copied it into a Assets/Plugins folder.
  • Note that my project has lots of dependencies, external packages, and other native plugins, such as though for Cesium for Unity for example. It is also a Git project.

Here is how I can workaround the bug:

  1. Initial plugin settings: work for any platform and do not load on startup. Hit Play, and observe exception DllNotFoundException: sqlite3.dll assembly:<unknown assembly> type:<unknown type> member:(null)
  2. Stop game, then exclude Editor from plugin platform, and apply.
  3. Play game, and the dll is now successfully imported despite being excluded from Editor.

Troubleshooting so far

  1. This bug is unique to this specific project on this specific machine. Other PCs do not encounter this.
  2. Testing in vanilla Unity projects on the problematic machine, this issue doesn’t occur, and I can load the DLL fine the first time.
  3. Checked PATH variable for any other sqlite3* files and found none.
  4. Works if I set LibraryPath to absolute path to the dll
  5. Doesn’t work if I update LibraryPath to sqlite3.dll

Anyone have any ideas on how to further troubleshoot? Why would Applying with “Editor Excluded” then reapplying with “Editor Included” for the plugin make it work?

Have you tried deleting the Library folder? With the project closed, and wait till delete is complete, then reopen.

Also worth trying is to upgrade to the latest patch release 42f1.

Yes, I’ve tried deleting the Library folder at least once. I was hoping to avoid having to upgrade to another version, but I may give that a go.

Updating patch level versions is generally safe, and sound whenever you encounter issues since they mainly contain bugfixes.

Updating patch level didn’t help. The workaround I have is sufficient, but it is strange to me still why it works. I wonder if my other dependencies in the project are surreptitiously interfering