SQLite Forum

PreLoadSQLite_LibraryFileNameOnly
Login

PreLoadSQLite_LibraryFileNameOnly

(1) By appel (appel_) on 2021-06-10 12:34:46 [link] [source]

When using System.Data.SQLite in a project that is hosted as an add-in problems occur if the customer has multiple add-ins that uses sqlite because you can end up with the wrong version of Sqlite.Interop.dll.

To work-around this we've had to compile our own System.Data.SQLite that appends the current version to the interop filename. We'd like to move away from this if possible and use the offical NuGet package.

Is there any way to use PreLoadSQLite_LibraryFileNameOnly instead and have the installer rename the interop dlls? Looking at the source it doesn't look like it would work because "SQLite.Interop.dll" looks to be hardcoded in the assembly.

(2) By mistachkin on 2021-06-10 17:13:28 in reply to 1 [link] [source]

The PreLoadSQLite_LibraryFileNameOnly setting is not designed to be used in this
way.

I think in order to accomplish what you are wanting, the existing P/Invoke layer
would have to switch to dynamically created delegates, i.e. no DllImport and no
need for a constant SQLITE_DLL.  That would be a large change in behavior, which
would risk breaking backwards compatibility.

(3) By appel (appel_) on 2021-06-10 20:14:55 in reply to 2 [source]

I suspected as much. Time to go back and figure out why building System.Data.SQLite.dll myself leads to "bad parameter or other API misuse" errors when opening a db.

Thanks.