How to add SQLite (SQLite.NET) to my C# project
Posted
by Lirik
on Stack Overflow
See other posts from Stack Overflow
or by Lirik
Published on 2010-04-19T05:32:01Z
Indexed on
2010/04/19
5:33 UTC
Read the original article
Hit count: 1071
I followed the instructions in the documentation:
Scenario 1: Version Independent (does not use the Global Assembly Cache)
This method allows you to drop any new version of the System.Data.SQLite.DLL into your application's folder and use it without any code modifications or recompiling. Add the following code to your app.config file:
<configuration>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite"/>
<add name="SQLite Data Provider" invariant="System.Data.SQLite"
description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
</DbProviderFactories>
</system.data>
</configuration>
My app.config file now looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="DataFeed.DataFeedSettings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<DataFeed.DataFeedSettings>
<setting name="eodData" serializeAs="String">
<value>False</value>
</setting>
</DataFeed.DataFeedSettings>
</userSettings>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite"/>
<add name="SQLite Data Provider"
invariant="System.Data.SQLite"
description=".Net Framework Data Provider for SQLite"
type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
</DbProviderFactories>
</system.data>
</configuration>
My project is called "DataFeed":
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SQLite; //<-- Causes compiler error
namespace DataFeed
{
class Program
{
static void Main(string[] args)
{
}
}
}
The error I get is:
.\dev\DataFeed\Program.cs(5,19): error CS0234: The type or namespace name 'SQLite' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
I'm not using the GAC, I simply dropped the System.Data.SQLite.dll
into my .\dev\DataFeed\
folder. I thought that all I needed to do is add the DLL to the project folder as it was mentioned in the documentation. Any hints on how to actually make this work?
© Stack Overflow or respective owner