35

I am currently using SQLite for Windows Forms but while running the project it is showing the error:

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

I had added the DLL of System.Data.SQLite.dll but it is showing the same error. Please can any one help me by giving the perfect answer regarding this problem? Thanks in advance

SharpC
  • 6,974
  • 4
  • 45
  • 40
user580927
  • 549
  • 2
  • 6
  • 10
  • 2
    I had the same problem, the solution was: Download and install VSIX package `sqlite-winrt81-3080403.vsix` from http://www.sqlite.org/download.html and select _Solution Explorer/References/Add reference.../Windows/Extensions/SQLite for Windows Runtime (Windows 8.1)_. I am using SQLite, and previously I installed NuGet Package `sqlite-net`. – marbel82 May 07 '14 at 08:53
  • Try this example.This worked for me. Windows 10 universal apps http://stackoverflow.com/a/33331478/3509494 – Kavinda Gehan Nov 29 '15 at 18:03
  • For an updated solution, use the [SQLitePCLRaw.bundle_e_sqlite3](https://www.nuget.org/packages/SQLitePCLRaw.bundle_e_sqlite3) package. – Metro Smurf Dec 08 '22 at 18:54

14 Answers14

25

This should fixed my issue. Add the following DLLs.

  • Microsoft Visual C++ Runtime Package
  • SQLite for Windows Runtime

enter image description here

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
SurenSaluka
  • 1,534
  • 3
  • 18
  • 36
  • 3
    this is the actual solution. this one should be marked is Answer. – Zia Ur Rahman Jul 20 '16 at 18:43
  • 4
    I am using classic desktop library project and when I press on 'Add reference' I do not have section 'Windows' at all. Where I can fin it? – LaoR Sep 04 '16 at 17:46
  • Hi, you need to right click on "References" -> "Manage NuGet Packages". On the "Browse" tab look for "System.Data.SQLite". Install it. No need to manually add reference. Let us know how it turned out. Cheers! – SurenSaluka Sep 05 '16 at 04:31
  • I've installed "System.Data.SQLite" but I don't see it in my Reference manager... – Denny Nov 21 '16 at 18:03
  • Hi Danny could you explain your scenario in detail? – SurenSaluka Nov 21 '16 at 18:22
  • 1
    I have this error with visual studio 2017 (fine with 2015), I installed c++ package for 2017, installed SQLite runtime for windows, SQLite ADO.Net Provider for both x86, x64, added System.Data.SQLite, yeah, rebooted, yet still have the error :( – Elaine Apr 13 '17 at 07:51
  • @SurenSaluka Didn't "turn out" at all. Same issue as Elaine. Also installed the visx package, System.Data.SQLite, sqlite-net, and attempted to manually add the dll from the official binaries site. Still same issue. – maplemale Jan 02 '18 at 20:40
  • Hi, What is your project type? is it a UWP or a Windows 8 Store app? – SurenSaluka Jan 03 '18 at 11:48
13

Use Project "Add Existing Item" and select the sqlite3.dll "As link". Click OK. Choose DLL in project and set "Copy Local" value to True.

Andrey Koleda
  • 141
  • 1
  • 3
  • 1
    Why should we select it "As Link"? Can we just copy it and then set the properties to "Copy Always"? – Ebsan May 07 '15 at 01:48
12

Maybe you haven't added the version for the right platform? SQLite is distributed with one X86 (32 bit) assembly and one X64 (64 bit) assembly.

If your application is a 32 bit application you should use the System.Data.SQLite.dll located in the "bin" directory of the System.Data.SQLite distribution, if it is a 64 bit application you should use the one in "bin\x64".

However, from looking at the error message a second time I'm not sure if that's it. Are you making native calls to SQLite? In that case you may have to rename the dll to sqlite3.dll.

As you may know System.Data.SQLite is a bundling of the original native sqlite3.dll and a managed ADO.NET provider (unless you are using some old version in which case I'm not sure - you might need the native sqlite3.dll separately)

Yhrn
  • 1,063
  • 7
  • 16
  • If your application is a 32 bit application you should use the System.Data.SQLite.dll located in the "bin" directory of the System.Data.SQLite distribution, if it is a 64 bit application you should use the one in "bin\x64". – Yhrn Jan 20 '11 at 08:41
  • Added more suggestions in the original answer as the comment would have been too long. – Yhrn Jan 20 '11 at 08:51
  • What's really required is to understand where the various platforms (.NET, UWP, Xamarin, etc. etc. are looking for the DLL). I can sometimes get SQLite to work, but I have no idea why or how. It's like sometimes it figures out where the DLL is by ozmosis. Other times I drop the DLL in the runtime folders and still get the same error. How does it actually work out where the DLL is? – Christian Findlay Sep 11 '16 at 02:27
3

In my case I'm working on a UWP project. I had to add a reference to Visual C++ 2015 Runtime for Universal Windows Platform Apps and the error was gone. It can be added in the Reference Manager under Universal Windows > Extensions. Detailed solution can be found here.

Community
  • 1
  • 1
testing
  • 19,681
  • 50
  • 236
  • 417
3

After struggling for 3 days,finally found a way to resolve.

As of March 2018,if you try to use sqlite-net via Nuget Package Manager,it adds two files and few reference dlls to your solution independent of type of project UWP or Android etc.

enter image description here

And after that if you compile and run the solution will fail with an exception

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

This is because it is unable to load sqlite3.dll as it is not added to the solution via NUGET package manger.So you need to add it manually.

To add,first determine your project is 32 bit or 64 bit then download the respective Precompiled Binaries for Windows Runtime from https://www.sqlite.org/download.html and add them manually (copy and paste).

So now your solution will look like below one and it will run without issues. enter image description here

Hameed Syed
  • 3,939
  • 2
  • 21
  • 31
2

I had exactly the same problem for the UWP project in a Xamarin.Forms application. Adding reference to "SQLite for Universal Windows Platform" to the UWP project solved the problem. enter image description here

Jean-Daniel Gasser
  • 496
  • 2
  • 8
  • 16
  • In my case the extension did not appear I had to install it => https://marketplace.visualstudio.com/items?itemName=SQLiteDevelopmentTeam.SQLiteforUniversalWindowsPlatform – Elias Platek Dec 11 '17 at 09:45
  • It worked for me after installing SQLite's Universal Windows Platform version as found https://www.sqlite.org/download.html. – ramya Aug 15 '19 at 11:55
2

I had the same issue when I downloaded the latest sqlite provider and I tried a solution from here but it didnt work, hence I downloaded the earlier version and its works fine.

Community
  • 1
  • 1
Coder323
  • 580
  • 6
  • 17
2

Had this problem recently - after attaching procmon to my process, I found that the latest System.Data.SQLite libs (the ones built for .NET4) have a dependency on the MSVC 2010 runtime, and the servers didn't have this installed. Fortuantly, this can be pulled down from the Microsoft website.

Chris J
  • 30,688
  • 6
  • 69
  • 111
1

Copy sqlite3.dll to the System32 folder. It worked for me. And thanks too!

1

I'm building a native Windows Phone 8.1 app with a PCL and a Droid project. I had the same error and I put the reference to the right version of sqlite3.dll (wpa81) and all worked.

Philip Allgaier
  • 3,505
  • 2
  • 26
  • 53
Danilo
  • 11
  • 1
1

Especially if you've updated to Visual Studio 2015 RTM and are developing Universal Windows apps, try uninstalling the SQLite for Universal App Platform extension and reinstalling (see http://sqlite.org/download.html).

matthewsheets
  • 4,535
  • 2
  • 15
  • 11
1

All of these seem to be solutions for certain situations. For me, and for @Marlon Ticao on this page, the application just can't find the DLL.

There are 2 solutions. Copy it to a directory that is in you path (such as System32) or you can copy it into the same directory that your executable is.

Jason Geiger
  • 1,912
  • 18
  • 32
0

I had this exact problem using a 3rd party built sqlite3.dll -- the app would not launch. I used the dependency walker to find that this sqlite3.dll had a dependency on msvcr110.dll. Once I included this file, all was well.

cbc700
  • 1
  • 1
0

Don't forget to deploy the published runtimes folder too in .NET (Core) projects, it should contain that DLL for various targets.

AyCe
  • 727
  • 2
  • 11
  • 30