1
votes

EDIT: Ok, I noticed I changed the output folder of the project and put the DLL into the old output folder. After putting it in the right output folder Open() works! I get another exception later, but I guess I can fix that...

I am working on a program that is running on .NET on Windows and on Mono on Linux/Mac. I'm trying to add a very simple SQLite logger to it. I added the Mono.Data.Sqlite.dll (of Mono 3.10) to the project references in Visual Studio 2013 and copied a sqlite3.dll (http://www.sqlite.org/2014/sqlite-dll-win32-x86-3080701.zip) into the debug folder (where the program exe is created).

This is my test code:

using Mono.Data.Sqlite;
using System.Data;

namespace Program.Logging
{
    class MyLogger
    {
        public void TestMethod()
        {
            string connectionString = "URI=file:SqliteTest.db";
            IDbConnection dbcon;
            dbcon = (IDbConnection)new SqliteConnection(connectionString);
            dbcon.Open();
        }   
    }
}

But when I try to run the code I get this error at dbcon.Open():

An unhandled exception of type 'System.EntryPointNotFoundException' occurred in Mono.Data.Sqlite.dll

Additional information: Der Einstiegspunkt "sqlite3_next_stmt" wurde nicht in der DLL "sqlite3" gefunden. (The entry point "sqlite3_next_stmt" was not found in the DLL "sqlite3".)

What am I doing wrong?

EDIT:

string connectionString = "Data Source=file:SqliteTest.db";

An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll. Additional information: URI-Formate werden nicht unterstützt. (URI formats aren't supported.)

string connectionString = "URI=file:SqliteTest.db,version3";

An unhandled exception of type 'System.ArgumentException' occurred in Mono.Data.Sqlite.dll. Additional information: Invalid ConnectionString format for parameter "version3"

1

1 Answers

0
votes

It appears you are using the wrong connection string format. The documentation specifies the connection string formats:

[1.1 profile and the old assembly]
URI=file:/path/to/file

[2.0 profile in the new assembly]
Data Source=file:/path/to/file

Since you are targeting sqlite3, I guess you should be using the 2.0 profile format.

string connectionString = "Data Source=file:SqliteTest.db";

They also mention that in the 1.1 profile, sqlite version 2 is used by default, you would have to specify the version if you want to use if you use the old format.

string connectionString = "URI=file:SqliteTest.db,version=3";