Answered by:
Cannot add sqlite3.dll as a reference

Question
-
I downloaded 64-bit DLL (x64) for SQLite version 3.12.2. C# -> References -> Add Reference -> Browse -> sqlite3.dll -> OK.
The result is this message: "A reference to sqlite3.dll could not be added. Please make sure that file is accessible and that it is valid assembly or com component."
I tried the 32 bit version ... same message.
bhs67
- Edited by bhs67 Sunday, May 8, 2016 9:44 PM
Sunday, May 8, 2016 9:43 PM
Answers
-
Just try to run "Install-Package System.Data.SQLite" from the Package Manager Console, or search for the name "System.Data.SQLite" in "Package Manager" (Right-click your project -> "Manage NuGet Packages..." If your Visual Studio had never installed NuGet before, you should be able to add it by "Tools" -> "Extension Manager" and install "NuGet Package Manager" there) and install it there. NuGet should select the appropiate package and add the reference for you.
- Edited by cheong00Editor Monday, May 9, 2016 1:50 AM
- Proposed as answer by DotNet Wang Monday, May 9, 2016 7:42 AM
- Marked as answer by DotNet Wang Monday, May 16, 2016 12:40 PM
Monday, May 9, 2016 1:41 AMAnswerer -
When you add System.Data.SQLite from NuGet, NuGet will add the required libraries for you. That's the whole point of having a package manager.
To know whether you need to distribute the files with your project, just take a look on "Properties" of each of the reference (click on them and press F4 if the docking window is not already opened). If "Copy Local" is true, you need to distribute the DLL, if not, you can skip it.
======
Just in case you really want to know, System.Data.SQLite v1.0.101.0 depends on System.Data.SQLite.Core v1.0.101.0+ System.Data.SQLite.Linq v1.0.101.0+ and System.Data.SQLite.EF6 v1.0.101.0+.
Out of these 3 packages, only System.Data.SQLite.EF6 have dependency on EntityFramework v6.0.0.0+.
And then the EntityFramework have dependency on System.ComponentModel.DataAnnotations which is part of the .NET runtime.
Therefore 4 sets of libraries is needed.
Monday, June 6, 2016 2:22 AMAnswerer -
If you try and open System.Data.SqLite in NuGet Package Explorer, you'll see that "System.Data.SQLite v1.0.101.0" is just a stub package that hosts the dependency information and does not have actual package content. the "System.Data.SqLite.dll" comes from "System.Data.SQLite.Core v1.0.101.0" instead. As shown in the pic below.
For EntityFramework package, it contains EntityFramework and EntityFramework.SqlServer as you have already discovered.
- Marked as answer by bhs67 Wednesday, June 8, 2016 10:34 AM
Tuesday, June 7, 2016 1:49 AMAnswerer -
And my previous post means System.Data.SQLite itself is empty package and does not contain binaries. The package exists just to host the dependency information.
NuGet Package Explorer can be downloaded here. It enables you to get an idea on what's inside the packages.
- Marked as answer by bhs67 Wednesday, June 8, 2016 10:34 AM
Wednesday, June 8, 2016 1:51 AMAnswerer
All replies
-
Check your download source.
See System.Data.SQLite Downloads for the correct .Net version installer.
Sunday, May 8, 2016 9:58 PM -
It is challenging to read, and understand, that web page. Plus it keeps referencing C++ ... nothing about C#.
It appears I should run one of the .exe's. Will that create a .dll?
If I understand correctly, the "static" is more flexible for use on different computers. I don't understand the "mixed-mode".
I am using C# .NET 4.5.1 ... want a simple flat file database that will work on different machines.
I was planning to follow the tutorial at http://blog.tigrangasparian.com/2012/02/09/getting-started-with-sqlite-in-c-part-one/.
Any recommendations?
bhs67
Sunday, May 8, 2016 10:46 PM -
Just try to run "Install-Package System.Data.SQLite" from the Package Manager Console, or search for the name "System.Data.SQLite" in "Package Manager" (Right-click your project -> "Manage NuGet Packages..." If your Visual Studio had never installed NuGet before, you should be able to add it by "Tools" -> "Extension Manager" and install "NuGet Package Manager" there) and install it there. NuGet should select the appropiate package and add the reference for you.
- Edited by cheong00Editor Monday, May 9, 2016 1:50 AM
- Proposed as answer by DotNet Wang Monday, May 9, 2016 7:42 AM
- Marked as answer by DotNet Wang Monday, May 16, 2016 12:40 PM
Monday, May 9, 2016 1:41 AMAnswerer -
Sorry for the slow response.
I have executed "Install-Package System.Data.SQLite" successfully. I see a lot of .dll's.
Is there a specific one to use for Visual Studio C# code .NET 4.5.1? I see quite a few under "packages".
bhs67
Sunday, June 5, 2016 5:12 PM -
When you add System.Data.SQLite from NuGet, NuGet will add the required libraries for you. That's the whole point of having a package manager.
To know whether you need to distribute the files with your project, just take a look on "Properties" of each of the reference (click on them and press F4 if the docking window is not already opened). If "Copy Local" is true, you need to distribute the DLL, if not, you can skip it.
======
Just in case you really want to know, System.Data.SQLite v1.0.101.0 depends on System.Data.SQLite.Core v1.0.101.0+ System.Data.SQLite.Linq v1.0.101.0+ and System.Data.SQLite.EF6 v1.0.101.0+.
Out of these 3 packages, only System.Data.SQLite.EF6 have dependency on EntityFramework v6.0.0.0+.
And then the EntityFramework have dependency on System.ComponentModel.DataAnnotations which is part of the .NET runtime.
Therefore 4 sets of libraries is needed.
Monday, June 6, 2016 2:22 AMAnswerer -
Thanks for the clear, concise description.
I count five libraries in your post:
System.ComponentModel.DataAnnotations
System.Data.SQLite v1.0.101.0
System.Data.SQLite.Core v1.0.101.0
System.Data.SQLite.Linq v1.0.101.0
System.Data.SQLite.EF6 v1.0.101.0
In my code, after installing via NuGet, I see four libraries:
System.ComponentModel.DataAnnotations
System.Data.SQLite v1.0.101.0
System.Data.SQLite.Linq v1.0.101.0
System.Data.SQLite.EF6 v1.0.101.0I also see the addition of these:
EntityFramework
EntityFramework.SqlServer
bhs67
Monday, June 6, 2016 11:26 AM -
If you try and open System.Data.SqLite in NuGet Package Explorer, you'll see that "System.Data.SQLite v1.0.101.0" is just a stub package that hosts the dependency information and does not have actual package content. the "System.Data.SqLite.dll" comes from "System.Data.SQLite.Core v1.0.101.0" instead. As shown in the pic below.
For EntityFramework package, it contains EntityFramework and EntityFramework.SqlServer as you have already discovered.
- Marked as answer by bhs67 Wednesday, June 8, 2016 10:34 AM
Tuesday, June 7, 2016 1:49 AMAnswerer -
Not sure how to launch NuGet Package Explorer ... but it probably doesn't matter.
I think the previous post means I don't need to see System.Data.SQLite.Core v1.0.101.0 ... it's part of System.Data.SQLite.
bhs67
Tuesday, June 7, 2016 1:03 PM -
And my previous post means System.Data.SQLite itself is empty package and does not contain binaries. The package exists just to host the dependency information.
NuGet Package Explorer can be downloaded here. It enables you to get an idea on what's inside the packages.
- Marked as answer by bhs67 Wednesday, June 8, 2016 10:34 AM
Wednesday, June 8, 2016 1:51 AMAnswerer -
I was having exactly the same problem as OP, NuGet was not finding SQLite at all. Cheong00's response worked flawlessly.
Thanks
Sunday, September 16, 2018 10:02 AM