SQLite with VS 2010

2

I'm working on a project and i need to use some database.I chose SQLite because of its easiness to use.But im having some trouble to get it work.I'm using System.Data.SQLite from http://sqlite.phxsoftware.com/ but when i try to run the program i get the following exception message.I'm coding C# with Visual Studio 2010..

Could not load file or assembly 'System.Data.SQLite, Version=1.0.66.0, Culture=neutral, PublicKeyToken=1fdb50b1b62b4c84, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)

I dont know why i get this and how to handle it.

I have to get this project ready for tomorrow and need your help...

c#
database
visual-studio
visual-studio-2010
sqlite
asked on Stack Overflow Feb 18, 2011 by thecodekid • edited Feb 19, 2011 by thecodekid

5 Answers

3

When you add a reference to the System.Data.SQLite assembly, make sure you set the property of "Copy Local" to true:

  1. Right click the assembly System.Data.SQLite
  2. Change "Copy Local" to True

This with the addition of Dillie-O's answer should get SQLite running on the .Net v4.0 Framework within VS 2010.

answered on Stack Overflow Feb 19, 2011 by Metro Smurf • edited May 23, 2017 by Community
2

There is a known issue with the .Net Framework 4 and SQLite according to this post, and this referenced post. The solution is to add the following section into your .config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" />
  </startup>
</configuration>

This will properly load the 2.0 assembly with the 4.0 framework. Apparently the current SQLite library is built as a .Net 2.0 assembly.

answered on Stack Overflow Feb 18, 2011 by Dillie-O • edited Feb 19, 2011 by Metro Smurf
1

If you need DBML layer stuff and LINQ to SQL Lite in your project, you're better off use DEVART's LinqExpress tools from www.devart.com.

Its free and it lets you build your model visually, then use the Linq generated classes in your project - wether VS Express or full monty mode.

Once LinqExpress for SQLLite is added to your project's references, it embarks the sqlLite dll too.

Please note: I have no shares in Devart company, but when I needed help with the free product, they helped me at no charge.

answered on Stack Overflow Feb 19, 2011 by Didier Levy
1

I also suffer from this exception. Here is my solution:

Modify app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" />
  </startup>
</configuration>

In "Solution Explorer -> {Project} -> Reference -> System.Data.SQLite" -> Properties -> Copy Local" , select "True"

You need to deploy project.exe and project.exe.config together.

I don't know why you need to deploy .config, but it doesn't work if I deploy project.exe without project.exe.config.

answered on Stack Overflow Jan 31, 2013 by Ray • edited Jan 31, 2013 by John Brodie
0

I met same problem as well. I am using VS express 2010 and sqlite(1.0.66.0). In fact, it works fine during my development and debugging, but after I deployed compiled dll into production server. I got this error. I realised that it was caused by different sqlite dll version, so I fixed it with below steps:

1) Install same sqlite version on the development machine with production server(the version is 1.0.87); 2) copy system.data.sqlite.dll from version 1.0.87 folder into .NET Framework assembly reference folder (C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0) which is used in VS express 2010 for .NET Framework 4.0

3) recompile the project to get new DLL 4) copy dll from step 3 onto the production server, then the issue was gone.

Also you may refer this blog: http://www.tsjensen.com/blog/post/2011/06/04/SQLite+On+Visual+Studio+2010+Setup+Instructions.aspx

answered on Stack Overflow Mar 26, 2014 by Ford

User contributions licensed under CC BY-SA 3.0