8

I'm having a bit of a senior moment trying to get SQLite working on a new WPF project. I've recently written a bunch of Windows Store and Phone projects and always used the same neat SQLite-net implementation there, but now I can't seem to do that with my WPF app.

I've added SQLite-net through nuget, but I can't find a version of SQLite3.dll that I can add to the project. When I download it from SQLite.org I get the following error.

enter image description here

What am I doing wrong? All the tutorials I find tell me to use System.Data.Sqlite instead but I don't want to rewrite all my DAL code again

1

2 Answers 2

9

I got it working.

For anyone who's trying to do this - specifically, trying to get sqlite-NET to work on WPF, not just SQLite, you need to:

  1. download the pre-compiled windows binary of sqlite3.dll from http://www.sqlite.org/download.html
  2. copy that dll file into your bin folder
  3. go to project properties > build and change the CPU type to x86 (there's no precompiled x64 version at time of writing)
Sign up to request clarification or add additional context in comments.

3 Comments

When you say 'into your bin folder', do you mean the bin folder of the project, or some other place? Nuget puts DLLs into a different directory, but that one is not called 'bin'. Also, how do you add a reference to the dll you just downloaded?
Attempted this - does not work for me. VS 2017, still has all the same issues.
0

You need to download and install an appropriate System.Data.SQLite setup package from http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki.

This will install the required SQLIte assemblies into your GAC and the design-time components for Visual Studio.

For .NET 4.5.1 (VS 2013) the current link is http://system.data.sqlite.org/downloads/1.0.92.0/sqlite-netFx451-setup-bundle-x86-2013-1.0.92.0.exe

For .NET 4.5 (VS 2012) the current link is http://system.data.sqlite.org/downloads/1.0.92.0/sqlite-netFx45-setup-bundle-x86-2012-1.0.92.0.exe

For .NET 4 (VS 2010) the current link is http://system.data.sqlite.org/downloads/1.0.92.0/sqlite-netFx40-setup-bundle-x86-2010-1.0.92.0.exe

Once you do that you will be able to add required SQLite assembly references in your project.

Here is a screenshot of SQLite assemblies in Add Reference dialog:

enter image description here

5 Comments

still not working for me... once I install one of these (in my case .net4) I get that I should be adding a reference, but from where? Where is the dll file?
It's in the GAC, so don't browse for it, just type in SQLite as soon as you open the add reference dialog.
Hi Dean. I actually have these added already, but SQLite-net is still throwing the same error. Here's the error: dl.dropboxusercontent.com/u/568631/sqlite-error-1.png, my references: dl.dropboxusercontent.com/u/568631/sqlite-error-2.png
looking back over your answer I strongly suspect this is aimed at a more generic implementation of sqlite rather than specifically implementing the sqlite-net wrapper library as is. Were I to get your implementation to work I'd have to rewrite my code, which is not what I wanted
Exactly - this in fact does work (adds references to manually write sqlite commands). But, I'm very disinclined to write my own wrapper for things like converting objects back and forth to/from sql results.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.