2014-11-14 147 views
1

編輯:好的,我注意到我更改了項目的輸出文件夾,並將該DLL放入舊的輸出文件夾中。將它放在正確的輸出文件夾Open()中後!我以後得到另一個異常,但我想我可以修復...在Visual Studio 2013的Windows上使用Mono.Data.Sqlite

我正在運行在Windows上和在Linux/Mac上的Mono上運行的程序。我試圖添加一個非常簡單的SQLite記錄器。我將Mono.Data.Sqlite.dll(Mono 3.10)添加到Visual Studio 2013中的項目引用中,並將sqlite3.dll(http://www.sqlite.org/2014/sqlite-dll-win32-x86-3080701.zip)複製到調試文件夾(創建程序exe的位置)。

這是我的測試代碼:

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(); 
     } 
    } 
} 

但是當我嘗試運行代碼,我在dbcon.Open()得到這個錯誤:

型系統的」未處理的異常。 EntryPointNotFoundException」 發生在Mono.Data.Sqlite.dll

其他信息:明鏡Einstiegspunkt 「sqlite3_next_stmt」 在德DLL 「sqlite3的」 gefunden wurde nicht。 (入口點 「sqlite3_next_stmt」 沒有在DLL 「sqlite3的」 發現。)

我在做什麼錯?

編輯:

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

類型 'System.ArgumentException' 未處理的異常發生在 mscorlib.dll中。其他信息:URI-Formate werden nicht unterstützt。 (URI格式不被支持。)

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

類型 'System.ArgumentException' 的未處理的異常發生在 Mono.Data.Sqlite.dll。附加信息:無效ConnectionString 參數「version3」的格式

回答

0

看起來您使用了錯誤的連接字符串格式。該documentation指定連接字符串格式:

[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 

既然你的目標sqlite3的,我想你應該使用2.0配置文件格式。

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

他們還提到,在1.1配置文件,任何版本2默認情況下使用,你就必須指定版本,如果你想,如果你使用舊格式使用。

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

我已經嘗試了建議的連接字符串的兩個版本,他們都拋出不同的例外。 – John 2014-11-14 17:40:58

+0

對不起,第二個版本有一個錯字,應該有'version = 3'。 – 2014-11-14 18:03:54

+0

我沒有在正確的輸出文件夾中的DLL。我之前更改了輸出文件夾並忘記了它,並將該DLL放入舊文件夾中... – John 2014-11-14 18:04:48