Description
Some of this was detailed in #19693. But at this point it deserves its own issue.
When executing ./bundle that was targetting SQLite, I got the error:
"System.DllNotFoundException: Unable to load shared library 'e_sqlite3' or one of its dependencies. "
I had this problem on two MacBooks (Big Sur) in VS Code. With the same project in VS Code on Windows , bundle succeeded.
I did a lot of testing and reading.
These two issues were useful reads and triggered the idea that finally led me to success although it is a HACK.
- Unable to load e_sqlite3.dll for Microsoft.EntityFrameworkCore.Sqlite 3.0.0 natemcmaster/DotNetCorePlugins#84
- DllNotFoundException: Unable to load DLL 'e_sqlite3' or one of its dependencies natemcmaster/DotNetCorePlugins#214
What ultimately worked was copying the osx/64 runtime file (in bin/debug /runtimes) into the same file path as bundle.exe.
Here you can see where bundle failed (before I copied the file) and then succeeded after I copied the file.
(Ignore the project name I was just reusing an existing project :) )
Obviously it's a hack but I don't know my way around this well enough to take this info and come up with the real problem and thereby a proper solution.
Include stack traces
➜ CosmosProviderSample git:(removeowned) ✗ ./bundle
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 shared library 'e_sqlite3' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libe_sqlite3, 1): image not found
at System.Runtime.InteropServices.NativeLibrary.LoadByName(String libraryName, QCallAssembly callingAssembly, Boolean hasDllImportSearchPathFlag, UInt32 dllImportSearchPathFlag, Boolean throwOnError) in System.Private.CoreLib.dll:token 0x6004664+0x41
at System.Runtime.InteropServices.NativeLibrary.LoadLibraryByName(String libraryName, Assembly assembly, Nullable`1 searchPath, Boolean throwOnError) in System.Private.CoreLib.dll:token 0x6004662+0x7
at System.Runtime.InteropServices.NativeLibrary.Load(String libraryName, Assembly assembly, Nullable`1 searchPath) in System.Private.CoreLib.dll:token 0x6004669+0xe
at SQLitePCL.NativeLibrary.Load(String libraryName, Assembly assy, Int32 flags) in SQLitePCLRaw.nativelibrary.dll:token 0x6000001+0x0
at SQLitePCL.Batteries_V2.MakeDynamic(String name, Int32 flags) in SQLitePCLRaw.batteries_v2.dll:token 0x6000002+0x10
at SQLitePCL.Batteries_V2.DoDynamic_cdecl(String name, Int32 flags) in SQLitePCLRaw.batteries_v2.dll:token 0x6000003+0x0
at SQLitePCL.Batteries_V2.Init() in SQLitePCLRaw.batteries_v2.dll:token 0x6000004+0x0
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) in System.Private.CoreLib.dll:token 0x6004d94+0x23
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) in System.Private.CoreLib.dll:token 0x6004c98+0x0
at Microsoft.Data.Sqlite.Utilities.BundleInitializer.Initialize() in Microsoft.Data.Sqlite.dll:token 0x60001d8+0x20
at Microsoft.Data.Sqlite.SqliteConnection..cctor() in Microsoft.Data.Sqlite.dll:token 0x60000a1+0x0
--- End of inner exception stack trace ---
at Microsoft.Data.Sqlite.SqliteConnection..ctor(String connectionString) in Microsoft.Data.Sqlite.dll:token 0x60000a3+0x0
at Microsoft.EntityFrameworkCore.Sqlite.Storage.Internal.SqliteRelationalConnection.CreateDbConnection() in Microsoft.EntityFrameworkCore.Sqlite.dll:token 0x6000159+0x0
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.get_DbConnection() in Microsoft.EntityFrameworkCore.Relational.dll:token 0x6000514+0x25
at Microsoft.EntityFrameworkCore.Diagnostics.RelationalLoggerExtensions.MigrateUsingConnection(IDiagnosticsLogger`1 diagnostics, IMigrator migrator, IRelationalConnection connection) in Microsoft.EntityFrameworkCore.Relational.dll:token 0x6001645+0x10
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration) in Microsoft.EntityFrameworkCore.Relational.dll:token 0x6000fc3+0x0
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String connectionString, String contextType) in Microsoft.EntityFrameworkCore.Design.dll:token 0x6000479+0x2e
at Microsoft.EntityFrameworkCore.Design.MigrationsBundle.ExecuteInternal(String context, Assembly assembly, Assembly startupAssembly, String[] args, String migration, String connection) in Microsoft.EntityFrameworkCore.Design.dll:token 0x60003da+0x4a
at Microsoft.EntityFrameworkCore.Design.MigrationsBundle.<>c__DisplayClass0_0.<Execute>b__0(String[] args) in Microsoft.EntityFrameworkCore.Design.dll:token 0x600065e+0x30
at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args) in Microsoft.EntityFrameworkCore.Design.dll:token 0x6000097+0x100
at Microsoft.EntityFrameworkCore.Design.MigrationsBundle.Execute(String context, Assembly assembly, Assembly startupAssembly, String[] args) in Microsoft.EntityFrameworkCore.Design.dll:token 0x60003d9+0xe5
The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception.
Include provider and version information
EF Core version: 6.0.0-rc.1.21409.2
EF Core Tools version: 6.0.0-rc.1.21409.2
Database provider: Microsoft.EntityFrameworkCore.Sqlite
Target framework: .NET 6.0
Operating system: Macos Big Sur
IDE: VS Code 1.59.0