SQLitePCL.raw: e_sqlite3.dll doesn't get loaded correctly
I’m working on a VS extension which uses Microsoft.Data.SQLite. I was using version 2.0.0, which depends on SQLitePCL.raw and I had to downgrade it to version 1.1.1 because e_sqlite3.dll doesn’t get loaded correctly.
Stack Trace
An error occurred: System.TypeInitializationException: The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.DllNotFoundException: Unable to load DLL 'e_sqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at SQLitePCL.SQLite3Provider_e_sqlite3.NativeMethods.sqlite3_libversion_number()
at SQLitePCL.SQLite3Provider_e_sqlite3.SQLitePCL.ISQLite3Provider.sqlite3_libversion_number()
at SQLitePCL.raw.SetProvider(ISQLite3Provider imp)
at SQLitePCL.Batteries_V2.Init()
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.Data.Sqlite.Utilities.BundleInitializer.Initialize()
at Microsoft.Data.Sqlite.SqliteConnection..cctor()
--- End of inner exception stack trace ---
at Microsoft.Data.Sqlite.SqliteConnection..ctor(String connectionString)
When debugging the extension, to find the cause of the issue, I looked at the Modules window and found out that the e_sqlite3 provider was being loaded from a Roslyn VS extension folder. In that folder there are two versions of e_sqlite3.dll, in subdirectories (x86 and x64). I tried copying the x86 version to the Roslyn VS extension folder and I didn't get the error, because DllImport found the assembly in the same folder as the one where the provider assembly is located.
Why isn’t e_sqlite3.dll being loaded? Is it supposed to be loaded from the x86 folder?
Any help would be appreciated.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 22 (9 by maintainers)
Commits related to this issue
- proper AssemblyVersion. #181 — committed to ericsink/SQLitePCL.raw by ericsink 6 years ago
SQLitePCL.raw pre-release version 1.1.10-pre20180223200113 has been pushed to nuget. From here forward, SQLitePCL.raw assemblies will include a properly updated AssemblyVersion. Testing feedback would be appreciated.