1

I have created a Winforms application and am using SQLite with Entity Framework 6. I am using Visual Studio 2013.

The application works perfectly on my local machine. However, when the program runs on another machine the following error occurs:

"Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found.

As far as I'm concerned, the problem is that the Interop dll isn't being copied to the directory when I publish my project.

My question is: How do I force this dll to copy to the correct directory when I publish the application?

3 Answers3

3

I found a workaround for my issue. I already had correctly installed all of the SQLite packages, yet the Interop.dlls were not copying over when I published the application.

What I did was build the project, and then went into the bin/Debug/ folders and copied the x86 and x64 folders that contained the SQLite.Interop.dll files. I then included those folders in my project. All if working fine now.

  • This is the way. Now the question is how we can make the copy automatically because I can't add a reference to the project of this file because VS doesn't recognize this file as an assembly or COM component. Thank you very much by the way :-) – Max Becerra Nov 04 '17 at 18:20
  • 1. With Visual Studio open, search and install SQLite.Core via the NUGET Package manager 2. In Solution explorer, Right click your PROJECT NAME-->ADD-->NEW FOLDER 3. Name the folder x64 4. Repeat the process and add folder and name it x86 5. Right click the x64 folder-->ADD-->EXISTING ITEM Then browse the DEBUG FOLDER. You will find the x64 folder. Select the "SQLite.Interop.dll" file then hit OK. 6. Repeat step 5 for the x86 folder. 7. Right click each DLL that you just added and select PROPERTIES. In the option Copy to Output Directory, choose Copy always – user3267567 Oct 06 '20 at 20:10
2

For posterity, if you added SQLite via NuGet and it's not copying you can add this into your csproj file and it should copy the x86 and the x64:

 <PropertyGroup> 
    <ContentSQLiteInteropFiles>true</ContentSQLiteInteropFiles>
    <CopySQLiteInteropFiles>false</CopySQLiteInteropFiles>
    <CleanSQLiteInteropFiles>false</CleanSQLiteInteropFiles>
    <CollectSQLiteInteropFiles>false</CollectSQLiteInteropFiles>
 </PropertyGroup>
b.pell
  • 3,873
  • 2
  • 28
  • 39
  • This worked for me, thank you. Do you know why this was required? – kopo222 Jan 29 '20 at 12:58
  • I believe the "ContentSQLiteInterpFiles" must be telling Visual Studio to copy those files to the output directory as content (which subsequently makes them available to your application when you compile it and run it). – b.pell Jan 29 '20 at 15:29
0

In Visual Studio set the SQLite.Interop.dll reference property "Copy Local" to true.

RagtimeWilly
  • 5,265
  • 3
  • 25
  • 41
  • 1
    There is no reference to SQLite.Interop.dll at all. I've tried adding it in manually but it doesn't exist on that list. How do I make it available? – Zachary Keeton Aug 03 '15 at 15:37
  • Go to Tools -> Library Package Manager -> Package Manager Console and then select the project you are publishing and enter: `Install-Package System.Data.SQLite` – RagtimeWilly Aug 03 '15 at 23:14