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 justsqlite3 - I got sqlite3.dll from the Windows x64 precompiled binaries here: SQLite Download Page. I copied it into a
Assets/Pluginsfolder. - 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:
- 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) - Stop game, then exclude Editor from plugin platform, and apply.
- Play game, and the dll is now successfully imported despite being excluded from Editor.
Troubleshooting so far
- This bug is unique to this specific project on this specific machine. Other PCs do not encounter this.
- Testing in vanilla Unity projects on the problematic machine, this issue doesn’t occur, and I can load the DLL fine the first time.
- Checked PATH variable for any other
sqlite3*files and found none. - Works if I set
LibraryPathto absolute path to the dll - 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?