SQLite Forum

Unable to load DLL 'SQLite.Interop.dll' (0x8007007E) using nuget version 1.0.114.4 of System.Data.Sqlite
Login

Unable to load DLL 'SQLite.Interop.dll' (0x8007007E) using nuget version 1.0.114.4 of System.Data.Sqlite

(1) By anonymous on 2021-06-22 12:41:28 [source]

Hi,

I just updated my project to version 1.0.114.4 of System.Data.Sqlite and I got an error when loading SQLite.Interop.dll. I was able to minimize to a simple example, available here https://github.com/andrewhickman/sqlite-repro

To reproduce, run this docker command (using windows containers) on the latest commit in that repository

docker build . -t sqlite-repro ; docker run -it --rm sqlite-repro

I get the following exception

Unhandled exception. System.DllNotFoundException: Unable to load DLL 'SQLite.Interop.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)
   at System.Data.SQLite.UnsafeNativeMethods.sqlite3_config_none(SQLiteConfigOpsEnum op)
   at System.Data.SQLite.SQLite3.StaticIsInitialized()
   at System.Data.SQLite.SQLiteLog.PrivateInitialize(String className)
   at System.Data.SQLite.SQLiteLog.Initialize(String className)
   at System.Data.SQLite.SQLiteConnection..ctor(String connectionString, Boolean parseViaFramework)
   at System.Data.SQLite.SQLiteConnection..ctor(String connectionString)
   at SqliteRepro.Program.Main(String[] args) in C:\source\Program.cs:line 10

Running the same command on the previous commit (37ec7a771d30ba1b6a0d506efc7d8ab858852e31), it runs successfully. The only difference is going from version 1.0.113.7 to 1.0.114.4 of System.Data.Sqlite

Just doing dotnet run in the repository works fine on both versions on my machine (again using Windows)

(2) By Larry Brasfield (larrybr) on 2021-06-22 13:56:59 in reply to 1 [link] [source]

This recent post describes a problem created by an MSBuild change which I suspect has led to your issue. Either getting an MSBuild update or manually specifying another target to get SQLite.Interop.dll copied should function as a work-around. Or you could just copy the DLL yourself until that update is generally available.

(3) By anonymous on 2021-07-17 14:30:32 in reply to 2 [link] [source]

This actually seems to be caused by some extra dependencies in the latest version of SQLite.Interop.dll.

Using dumpbin I compared the dependencies between version 1.0.113.7 and 1.0.114.4 and these new dependencies were added:

    mscoree.dll
             1801473F0 Import Address Table
             180186090 Import Name Table
                     0 time date stamp
                     0 Index of first forwarder reference

                          6F StrongNameSignatureVerificationEx
                          71 StrongNameTokenFromAssembly
                          62 StrongNameFreeBuffer
                           F CorBindToRuntimeEx
                          61 StrongNameErrorInfo

    WINTRUST.dll
             1801473E0 Import Address Table
             180186080 Import Name Table
                     0 time date stamp
                     0 Index of first forwarder reference

                          82 WinVerifyTrust

mscoree.dll is not available in in the mcr.microsoft.com/dotnet/core/runtime image I was using. If I copy it in from a different image, SQLite.Interop.dll is loaded successfully

(4) By Norbert Sz. (NorbertSzakacs) on 2022-02-16 12:02:41 in reply to 3 [link] [source]

I can confirm that a MSCOREE.DLL reference has been introduced for SQLite.Interop.dll in the Stub.System.Data.SQLite.Core.NetStandard nuget package somewhere between 1.0.113.0 and 1.0.115.5 (latest atm).

This dependency leads to exceptions like this:

Error Message:

System.DllNotFoundException : Unable to load DLL 'SQLite.Interop.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)

Stack Trace:

 at System.Data.SQLite.UnsafeNativeMethods.sqlite3_open_interop(Byte[] utf8Filename, Byte[] vfsName, SQLiteOpenFlagsEnum flags, Int32 extFuncs, IntPtr& db)  at System.Data.SQLite.SQLite3.Open(String strFilename, String vfsName, SQLiteConnectionFlags connectionFlags, SQLiteOpenFlagsEnum openFlags, Int32 maxPoolSize, Boolean usePool)

The used docker image was: mcr.microsoft.com/dotnet/sdk:6.0.101

Workarounds can be:

  • mscoree.dll deploy as content in the project
  • downrgade System.Data.SQLite to 1.0.113

(5) By Danny Horodniczy (dhorodniczy) on 2022-03-24 15:00:22 in reply to 4 [link] [source]

Hi Norbert,

I don't understand what you mean for the 1st workaround. Could you please elaborate? :)

I downgraded to System.Data.SQLite 1.0.113. Unfortunately, it has both:

netstandard2.0/SQLite.Interop.dll
netstandard2.1/SQLite.Interop.dll

as runtime dependencies, which I believe after updating to .NET 6 causes NETSDK1152, when performing a dotnet publish

NETSDK1152: Found multiple publish output files with the same relative path:
C:\Users\320161687\.nuget\packages\system.data.sqlite.core\1.0.113.1\runtimes\win-x64\native\netstandard2.0\SQLite.Interop.dll,
C:\Users\320161687\.nuget\packages\system.data.sqlite.core\1.0.113.1\runtimes\win-x64\native\netstandard2.1\SQLite.Interop.dll

(6.1) By mistachkin on 2022-03-25 00:40:40 edited from 6.0 in reply to 3 [link] [source]

Use of these functions is by design.  According to MSDN, these functions
are deprecated; however, they should still be available, e.g. the function
StrongNameSignatureVerificationEx:

https://docs.microsoft.com/en-us/dotnet/framework/unmanaged-api/strong-naming/strongnamesignatureverificationex-function

Any Windows installation that is missing these files and/or the exports being
used is broken.