Skip to content

System.DllNotFoundException: Unable to load DLL 'e_sqlite3' or one of its dependencies: The specified module could not be found. #763

Description

@SlowLogicBoy

Looks similar to #210

Code:

#r "nuget: Microsoft.Data.Sqlite, 8.0.8"

using Microsoft.Data.Sqlite;

var connection = new SqliteConnection(":memory:");

Error:

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' or one of its dependencies: The specified module could not be found. (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()
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
   --- End of inner exception stack trace ---
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at Microsoft.Data.Sqlite.SqliteConnection..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.Data.Sqlite.SqliteConnection..ctor(String connectionString)
   at Submission#0.<<Initialize>>d__0.MoveNext() in D:\Git\dotnetScript\sqlitetest.csx:line 5
--- End of stack trace from previous location ---
   at Dotnet.Script.Core.ScriptRunner.Execute[TReturn](String dllPath, IEnumerable`1 commandLineArgs) in C:\Users\runneradmin\AppData\Local\Temp\tmp8BAF\Dotnet.Script.Core\ScriptRunner.cs:line 110
PS D:\Git\dotnetScript> dotnet script --info
Version             : 1.5.0
Install location    : C:\Users\MyUser\.dotnet\tools\.store\dotnet-script\1.5.0\dotnet-script\1.5.0\tools\net8.0\any
Target framework    : net8.0
.NET Core version   : 8.0.8
Platform identifier : win
Runtime identifier  : win10-x64

Some other info that might be relevant:

    Directory:
    C:\Users\MyUser\AppData\Local\Temp\dotnet-script\D\Git\dotnetScript\sqlitetest.csx\execution-cache


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         10/3/2024  11:20 AM                obj
-a----         8/23/2023   9:33 PM        1691648 e_sqlite3.dll
-a----         7/18/2024  12:12 AM         172992 Microsoft.Data.Sqlite.dll
-a----         10/3/2024  11:20 AM          13824 script.dll
-a----         10/3/2024  11:20 AM             44 script.sha256
-a----         8/23/2023   9:41 PM           5120 SQLitePCLRaw.batteries_v2.dll
-a----         8/23/2023   9:38 PM          50688 SQLitePCLRaw.core.dll
-a----         8/23/2023   9:38 PM          35840 SQLitePCLRaw.provider.e_sqlite3.dll

Interesting, I noticed, that if I add a breakpoint while F5'ing sometimes it loads and sometimes it doesn't

Looks like it happens only if script needs compilation, if it runs from cache it runs fine, probably script is ran before all dlls are copied?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions