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 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:
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)
PROJECT_FOLDER\packages\System.Data.SQLite.Core.1.0.*.*\build\net40
In my case the
myProject.csproj
file did not have theSystem.Data.SQLite.Core.targets
defined. I added the following line and bothx64
andx86
versions ofSQLite.Interop.dll
are now copied for all build targets.I'm not sure what will happen when the NuGet package for
System.Data.SQLite.Core
gets updated and if the package path will need to be manually altered.With the
System.Data.SQLite.Core
NuGet package version 1.0.104, I had the same problem as @Eternal21 and @Patrick. That is, project A references SQLite and project B references A whereSQlite.Interop.dll
is not copied into the output directory of B.I found a solution that solves the trouble in project A rather than B which is a more robust solution since it fixes the problem once for all future projects refering to A. The
.targets
file of the NuGet package contains the following section:This section adds
SQLite.Interop.dll
as a reference that has to be copied to project A's output and also to the output of refering projects (like B). But the MSBuild propertyContentSQLiteInteropFiles
is undefined by default (I don't know why) disabling the reference by the first condition. To enable it, I added the following line to aPropertyGroup
element of projects A's.csproj
file:Please note that this line must prececde the
Import
element for the.targets
file of the NuGet package.in my case using NuGet for installing SQLite and still I need to add manually SQliteinterop.dll as a Resource. Then I build muy proyect and when I publish it works fine. (Working with x86 configuration)
I have a DLL project that uses the SQLite package from nuget but a test project for it would always raise the DLL not found exception.
The simplest solution I found was to add the SQLite nuget package to the test project too.