I installed System.Data.SQLite Core (x86/x64) from NuGet. It built without warnings but threw System.DllNotFoundException
regarding SQLite.Interop.dll
. I rigged my projects to copy the SQLite.Interop.dll
from under the NuGet package's directory to the output directory, and now it runs without the exception.
Why didn't the NuGet package configure my projects to put the appropriate interop dll in the output directory? It seems like it should be able to do that.
I'm new to interop and I inherited this codebase, which previously referenced System.Data.SQLite.dll
directly by path. I switched to NuGet to get rid of warnings about a mismatch between the processor architecture of the project vs System.Data.SQLite
. I'm trying to build all projects as AnyCPU.
In my case the SQL.Interop.dll was not copied by Nuget in any way, manually put the right version of the dll in the x86 and x64 folder solved the issue. If you've installed Sqlite from Nuget, you can find the SQL.Interop.dll in this folder (for .NET 4.0)
Add a reference to the System.Data.SQLite.Core NuGet package OR one of the (parent) packages that have a dependency on it, e.g. System.Data.SQLite. Add a reference to the SQLite.Encryption.Extension NuGet package. When building for .NET Core, set the CopyLocalLockFileAssemblies MSBuild property in your project file.
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. This actually seems to be caused by some extra dependencies in the latest version of SQLite.Interop.dll.
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:
Copy this to your project file:
<PropertyGroup> <ContentSQLiteInteropFiles>true</ContentSQLiteInteropFiles> <CopySQLiteInteropFiles>false</CopySQLiteInteropFiles> <CleanSQLiteInteropFiles>false</CleanSQLiteInteropFiles> <CollectSQLiteInteropFiles>false</CollectSQLiteInteropFiles> </PropertyGroup>
Source: SQLite.Interop.dll files does not copy to project output path when required by referenced project
In my case, the problem was the fact that I was using SQLite inside a class library project that was then used by another WPF (gui type) project.
Solved the SQL.Interop.dll not getting copied to output directory, by using the following Post-Build command, inside Project Properties -> Build Events:
xcopy "$(SolutionDir)packages\System.Data.SQLite.Core.1.0.101.0\build\net451\x86\SQLite.Interop.dll" "$(OutputDir)" /y /f /y overwrites /f displays actual filenames being copied
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With