I'm having issues publishing a .NET Core console app. It works fine when I run it from Visual Studio and I'm getting zero errors. However, when I publish it with: dotnet publish -c release -r win-x64 --self-contained
I'm getting an error about SQLite. I'm using the Microsoft.EntityFrameworkCore.Sqlite library. The error I'm getting is:
Exception has been thrown by the target of an invocation. --->
Unable to load DLL 'e_sqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
I don't know what could be causing the issue and every single thing I find on the internet either doesn't work or doesn't apply to my situation. I really don't know what I'm doing wrong and I've tried just about everything.
If you're using the
System.Data.SQLite library then this exception is mentioned in their FAQ:
Why do I get a DllNotFoundException (for "sqlite3.dll" or "SQLite.Interop.dll") when trying to run my application?
Either the named dynamic link library (DLL) cannot be located or it cannot be loaded due to missing dependencies. Make sure the named dynamic link library is located in the application directory or a directory along the system PATH and try again. Also, be sure the necessary Visual C++ runtime redistributable has been installed unless you are using a dynamic link library that was built statically linked to it.
sqlite3.dllis in the same directory as the rest of your DLLs
sqlite3.dllmatches the ISA of your web-server process (i.e. ARM, x86, x64).
The SQLite EF Core provider is technically a 3rd-party library, from the point of view of the .NET Core. You need to make sure that the dependencies are fixed up for your project, according to this.
Basically, you need to make sure the dependency NuGet package is called out in your
.csproj file as a dependency, like so:
<ItemGroup> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="[version #]" /> </ItemGroup>
And you need to make sure the NuGet package is installed on your system, since the dependency is resolved from the local NuGet cache when the project is published.
User contributions licensed under CC BY-SA 3.0