Unable to load DLL 'SQLite.Interop.dll'

2019-01-02 17:26发布

Periodically I am getting the following exception:

Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

I am using 1.0.82.0. version, installing it with nuget in VS2010, OS Win7 64.

Once exception starts to appear, it appears constantly - in debug and release and running application within or outside VS.

The only way to stop it is logoff and logon. The exception is not thrown and dll is loaded. It can work for days, but then it can break again.

Has anyone seen something like this and is there a solution for it?

30条回答
还给你的自由
2楼-- · 2019-01-02 18:17

Could there be contention for the assembly? Check to see whether there's another application with a file lock on the DLL.

If this is the reason, it should be easy to use a tool like Sysinternal's Process Explorer to discover the offending program.

HTH, Clay

查看更多
还给你的自由
3楼-- · 2019-01-02 18:19

I ran across this problem, in a solution with a WebAPI/MVC5 web project and a Feature Test project, that both drew off of the same data access (or, 'Core') project. I, like so many others here, am using a copy downloaded via NuGet in Visual Studio 2013.

What I did, was in Visual Studio added a x86 and x64 solution folder to the Feature Test and Web Projects. I then did a Right Click | Add Existing Item..., and added the appropriate SQLite.interop.dll library from ..\SolutionFolder\packages\System.Data.SQLite.Core.1.0.94.0\build\net451\[appropriate architecture] for each of those folders. I then did a Right Click | Properties, and set Copy to Output Directory to Always Copy. The next time I needed to run my feature tests, the tests ran successfully.

查看更多
浪荡孟婆
4楼-- · 2019-01-02 18:20

There are really a lot of answers here, but mine is simple and clear with no-GAC-playing-around.

The problem was, the executable File needs a copy of the right SQLite.Interop.dll (x86 or x64) to access our Database.

Mostly architectures have layers and in my case the Data Layer has the required DLL for SQLite Connection.

So i simple put a post build script into my Data Layer Solution and everything worked fine.


TL;DR;

  1. Set all Projects of your solution to x86 or x64 in the build options.
  2. Add following Post-Build-Script to the Project with the SQLite nuget Package:

    xcopy "$(TargetDir)x64" "$(SolutionDir)bin\Debug\" /y

Of course you have to change the script for Release Build and x86 builds.


STL;DR;

Put your SQLite.Interop.dll next to the *.exe File.

查看更多
伤终究还是伤i
5楼-- · 2019-01-02 18:22

I had a similar issue in a multiple projects solution. The SQLite.Interop.dll was necessary for one of the plugins distributed with the software using ClickOnce.

As far as debugging in visual studio everything worked fine, but the deployed version was missing the folders x86/ and x64/ containing that DLL.

The solution to have it work after deployment using ClickOnce was to create in the startup project of the solution (also the one being published) these two subfolder, copy into them the DLLs and set them as Content Copy Always.

This way the ClickOnce publishing tool automatically includes these files and folders in the manifest and deploys the software with them

查看更多
听够珍惜
6楼-- · 2019-01-02 18:23

Copy "SQLite.Interop.dll" files for both x86 and x64 in debug folder. these files should copy into "x86" and "x64 folders in debug folder.

查看更多
裙下三千臣
7楼-- · 2019-01-02 18:23

I had this problem because a dll I was using had Sqlite as a dependency (configured in NuGet with only the Sqlite core package.). The project compiles and copies all the Sqlite dll-s except the 'SQLite.Interop.dll' (both x86 and x64 folder).

The solution was very simple: just add the Sqlite.Core package as a dependency (with NuGet) to the project you are building/running and the dll-s will be copied.

查看更多
登录 后发表回答