\"Unable to load DLL 'SQLite.Interop.dll'

2019-08-10 09:12发布

问题:

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?

回答1:

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.



回答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>


回答3:

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