Unable to load e_sqlite3.dll for Microsoft.EntityFrameworkCore.Sqlite 3.0.0
See original GitHub issueDescribe the bug
DllNotFoundException
thrown when using a plugin that consumes Microsoft.EntityFrameworkCore.Sqlite 3.0.0
. If I downgrade EFCore.Sqlite to 2.2.6, the plugin works fine.
System.TypeInitializationException: 'The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception.'
DllNotFoundException: Unable to load DLL 'e_sqlite3' or one of its dependencies: The specified module could not be found. (0x8007007E)
To Reproduce Steps to reproduce the behavior: Version: 0.3.1 Code (In the main program):
public Assembly Load(string assemblyName)
{
return PluginLoader.CreateFromAssemblyFile(assemblyName).LoadDefaultAssembly();
}
The plugin connects to a Sqlite3 database with Microsoft.EntityFrameworkCore.Sqlite 3.0.0
and print data to Console
. (See the screenshot for details)
Expected behavior
The plugin should not throw DllNotFoundException
.
Screenshots
Additional context
If I copy “e_sqlite3.dll” from “plugins\runtimes\win-x64\native\e_sqlite3.dll” to the “plugins” directory, the plugin won’t throw DllNotFoundException.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:15 (4 by maintainers)
Top Results From Across the Web
Entity Framework Core: Unable to load DLL 'sqlite3': The ...
I use Entity Framework Core in a UWP Project. When I start the application it creates the database. and can basicly access it....
Read more >Microsoft.EntityFrameworkCore.Sqlite 7.0.10
Version Downloads Last updated
8.0.0‑preview.7.23375.4 2,449 12 days ago
8.0.0‑preview.6.23329.4 9,013 a month ago
8.0.0‑preview.5.23280.1 10,359 2 months ago
Read more >SpatialiteLoader Class
Loads the mod_spatialite extension into the specified connection. TryLoad(DbConnection). Tries to load the mod_spatialite extension into the specified ...
Read more >EF Core Query - Page 2
This will download MySql.Data.EntityFrameworkCore.dll itself and all its dependencies. Please use these dependencies via a standalone Entity ...
Read more >Unable to load DLL 'SQLite.Interop.dll' (0x8007007E) using ...
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 ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry, but I don’t think there is anything I can do to fix this error. Under the hood, EF Core’s SQLite provider uses https://github.com/ericsink/SQLitePCL.raw. The way SQLitePCLRaw.nativelibrary is attempting to load the “e_sqlite3.dll” library circumvents this essential callback in
System.Runtime.Loader.AssemblyLoadContext
.The root cause appears to be the use of
System.Runtime.InteropServices.NativeLibrary
. This doesn’t account for the currentAssemblyLoadContext
or theruntimes/$rid/native/*.dll
layout.System.Runtime.Loader.AssemblyDependencyResolver
might be a better library for SQLitePCLRaw to use, but I’ll leave that up to @ericsink.Workaround
Change your plugin deployment to include a runtime identifier.
dotnet publish --runtime win-x64
should do the trick.Hi guys,
I was also facing the same issue. I found the solution and it’s working perfectly for me. If you ask I can write a detail note on the solution.