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?
I had the same issue running Visual Studio Express 2013. I tried several solutions mentioned here and elsewhere to no avail. I hope this fix helps others.
I fixed it by using the
DeploymentItem
attribute on my test class that tests the SQLite-based service.Example:
This causes the needed
SQLite.Interop.dll
to get copied to thex86
directory within the appropriate "TestResults" folder.All is green. All is good.
The default installation of the multi-architecture (x86, x64) version of SQLite from NuGet exhibits the behavior that you described. If you would like to load the correct version for actual architecture that the .NET runtime chose to run your application on your machine, then you can give the DLL loader a hint about where to locate the correct library as follows:
Add a declaration for the kernel32.dll function call to SetDLLDirectory() before your Program.Main():
Then use your own method for determining the correct subdirectory to find the architecture specific version of 'SQLite.Interop.dll'. I use the following code:
Try to set the platform target to x86 or x64 (and not Any CPU) before you build: Project->Properties->Build->Platform target in Visual Studio.
Updating NuGet from
Tools -> Extension and updates
and reinstalling SQLite.Core with the commandPM> Update-Package -reinstall System.Data.SQLite.Core
fixed it for me.I've struggled with this for a long time, and, occasionally, I found that the test setting is incorrect. See this image:
I just uncheck the test setting, and the issue disappears. Otherwise, the exception will occurs. Hopefully, this will help someone. Not sure it's the root cause.
As the SQLite wiki says, your application deployment must be:
So you need to follow the rules. Find dll that matches your target platform and put it in location, describes in the picture. Dlls can be found in YourSolution/packages/System.Data.SQLite.Core.%version%/.
I had problems with application deployment, so I just added right SQLite.Interop.dll into my project, the added x86 folder to AppplicationFolder in setup project and added file references to dll.