2010-06-04 84 views
5

我下載了System.Data.SQLite,並試圖編譯下面的示例代碼。如何在單聲道下使用System.Data.SQLite?

 
using System; 
using System.Data; 
using System.Data.Common; 
using System.Data.SQLite; 

namespace test 
{ 
    class Program 
    { 
    static void Main(string[] args) 
    { 
     SQLiteConnection.CreateFile("/Users/smcho/Desktop/SQLite-1/example/mydatabasefile.db3"); 
    } 
    } 
} 

我跑以下命令

 
mcs db.cs -r:System.Data.dll -r:System.Data.SQLite.dll 

但是,我得到了錯誤的信息如下。

 
** (/opt/local/lib/mono/1.0/mcs.exe:43249): WARNING **: The class System.Data.Common.DbConnection could not be loaded, used in System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
db.cs(12,7): error CS0103: The name `SQLiteConnection' does not exist in the current context 
Compilation failed: 1 error(s), 0 warnings 

什麼可能是錯誤的?

回答

4

使用gmcs代替mcs解決了這個問題。

 
gmcs db.cs -r:System.Data.dll,System.Data.SQLite.dll 
+0

mcs現在已經死亡(對於.NET 1.x/Mono 1.x)。應該使用gmcs(對於.NET 2.0 +/Mono 2.x)。 – 2010-06-05 11:24:04

相關問題