roryok
roryok

Reputation: 9645

Using SQLite-net in a WPF app

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

Upvotes: 8

Views: 15193

Answers (2)

roryok
roryok

Reputation: 9645

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)

Upvotes: 9

Dean Kuga
Dean Kuga

Reputation: 12119

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

Upvotes: 0

Related Questions