I'm writing a Unity Plugin in C#, that use SQLite.
The SQLite dependency to SQLite.Interop.dll, as I'm understanding this is a unmanaged DLL.
When I export my Unity plugins, there are several DLL files were exported along with my plugin.
Bin folder
|
|_ MyPlugin.dll
|_ System.Data.SQLite.dll
|_ (other files)
|_ x86
| |_ SQLite.Interop.dll
|
|_ x64
| |_ SQLite.Interop.dll
When using in the Unity game project, I put all the files under Assets/Plugins/MyPlugin as below:
Assets
|
|_ Plugins
|_ MyPlugin
|_ MyPlugin.dll
|_ System.Data.SQLite.dll
|_ (other files)
|_ SQLite.Interop.dll (x64 version)
In Unity editor, everything is OK, I can establish SQLite connection and do the transaction.
However, when exporting the Unity project to standalone application for Windows x64, it doesn't work and it throws error say that DllNotFoundException.
System.DllNotFoundException: SQLite.Interop.dll
at (wrapper managed-to-native) System.Data.SQLite.UnsafeNativeMethods:sqlite3_config_none (System.Data.SQLite.SQLiteConfigOpsEnum)
at System.Data.SQLite.SQLite3.StaticIsInitialized () [0x00000] in <filename unknown>:0
at System.Data.SQLite.SQLiteLog.Initialize () [0x00000] in <filename unknown>:0
at System.Data.SQLite.SQLiteConnection..ctor (System.String connectionString, Boolean parseViaFramework) [0x00000] in <filename unknown>:0
at System.Data.SQLite.SQLiteConnection..ctor (System.String connectionString) [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Data.SQLite.SQLiteConnection:.ctor (string)
at MyPlugin.Service.Util.SqliteBase.InitConnection () [0x00000] in <filename unknown>:0
at MyPlugin.Service.Util.SqliteBase.OpenConnection () [0x00000] in <filename unknown>:0
The folder structure of standalone application is as below:
Output
|_ UnityApp.exe
|_ UnityApp_Data
|
|_ Managed
| |_ MyPlugin.dll
| |_ System.Data.SQLite.dll
| |_ (other DLLs)
|
|_ Plugins
|_ SQLite.Intedrop.dll
The DLL is there but seem that Unity doesn't find it.
I found the solution to modify PATH environment variable here https://stackoverflow.com/a/33124250
It works, but I wonder if there is anything wrong with my configuration or is there any reason why Unity doesn't load SQLite.Intedrop.dll although it's existing in the application data folder.
I'm very appreciated any helps.
EDIT 1: The SQLite DLL is got by NUGET:
<package id="System.Data.SQLite" version="1.0.106.0" targetFramework="net35" />
<package id="System.Data.SQLite.Core" version="1.0.106.0" targetFramework="net35" />
<package id="System.Data.SQLite.Linq" version="1.0.106.0" targetFramework="net35" />