简体   繁体   English

在Visual Studio 2013中的Windows上使用Mono.Data.Sqlite

[英]Using Mono.Data.Sqlite on Windows in Visual Studio 2013

EDIT: Ok, I noticed I changed the output folder of the project and put the DLL into the old output folder. 编辑:好的,我注意到我更改了项目的输出文件夹,并将DLL放入旧的输出文件夹。 After putting it in the right output folder Open() works! 将其放在正确的输出文件夹中后,Open()起作用了! 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. 我正在研究在Windows上的.NET和Linux / Mac上的Mono上运行的程序。 I'm trying to add a very simple SQLite logger to it. 我正在尝试向其添加一个非常简单的SQLite记录器。 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). 我将Mono.10的Mono.Data.Sqlite.dll添加到Visual Studio 2013中的项目引用中,并复制了sqlite3.dll( http://www.sqlite.org/2014/sqlite-dll-win32-x86- 3080701.zip )到debug文件夹(在其中创建程序exe)。

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(): 但是,当我尝试运行代码时,在dbcon.Open()处出现此错误:

An unhandled exception of type 'System.EntryPointNotFoundException' occurred in Mono.Data.Sqlite.dll Mono.Data.Sqlite.dll中发生了类型为'System.EntryPointNotFoundException'的未处理异常

Additional information: Der Einstiegspunkt "sqlite3_next_stmt" wurde nicht in der DLL "sqlite3" gefunden. 附加信息:Der Einstiegspunkt“ sqlite3_next_stmt”在DLL“ sqlite3” gefunden中。 (The entry point "sqlite3_next_stmt" was not found in the DLL "sqlite3".) (在DLL“ sqlite3”中找不到入口点“ sqlite3_next_stmt”。)

What am I doing wrong? 我究竟做错了什么?

EDIT: 编辑:

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

An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll. mscorlib.dll中发生了'System.ArgumentException'类型的未处理异常。 Additional information: URI-Formate werden nicht unterstützt. 附加信息:URI格式不正确。 (URI formats aren't supported.) (不支持URI格式。)

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

An unhandled exception of type 'System.ArgumentException' occurred in Mono.Data.Sqlite.dll. Mono.Data.Sqlite.dll中发生了'System.ArgumentException'类型的未处理异常。 Additional information: Invalid ConnectionString format for parameter "version3" 附加信息:参数“ version3”的无效ConnectionString格式

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. 由于您的目标是sqlite3,所以我猜您应该使用2.0配置文件格式。

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. 他们还提到在1.1配置文件中,默认情况下使用sqlite版本2,如果要使用旧格式,则必须指定版本。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM