Mono上的SQLite错误 - SQLite.Interop.dll at(包装器托管到本机)

时间:2016-06-09 15:44:37

标签: c# xamarin sqlite mono

我正在尝试运行一个非常简单的C#代码来从SQLite中读取数据。我使用Xamarin作为我的IDE和Mac。我可以编译代码..但是当我尝试连接到SQLite数据库时,我收到此错误。任何想法我都缺少。

我使用Nuget包含了SQLite和SQLite.Data。我得到一个干净的构建错误是在运行时。我已将代码添加到错误的末尾

SQLite.Interop.dll at (wrapper managed-to-native) 

System.Data.SQLite.UnsafeNativeMethods:sqlite3_config_none     (System.Data.SQLite.SQLiteConfigOpsEnum)
      at System.Data.SQLite.SQLite3.StaticIsInitialized () <0x5934cd8 + 0x0007b> in <filename unknown>:0 
      at System.Data.SQLite.SQLiteLog.Initialize () <0x5934998 + 0x0001b> in <filename unknown>:0 
      at System.Data.SQLite.SQLiteConnection..ctor (System.String connectionString, Boolean parseViaFramework) <0x5932758 + 0x0003b> in <filename unknown>:0 
      at System.Data.SQLite.SQLiteConnection..ctor (System.String connectionString) <0x5932728 + 0x0001f> in <filename unknown>:0 
      at (wrapper remoting-invoke-with-check) System.Data.SQLite.SQLiteConnection:.ctor (string)



using System;
using System.Configuration;
using System.Linq;
using System.Data;
using System.Text;

using System.Data.SQLite;

using utils;

public class DataManager
{
    public static string GetData(string sql)
    {
        string JsonString = "{}";
        SQLiteConnection sqlLiteConnection = null;
        try
        {
            sqlLiteConnection = new SQLiteConnection(ConfigurationManager.ConnectionStrings["APP_DB"].ConnectionString);
            sqlLiteConnection.Open();

            SQLiteDataAdapter sqlDA = new SQLiteDataAdapter(sql, sqlLiteConnection);
            DataTable table = new DataTable();
            Logger.Log(sql);
            sqlDA.Fill(table);
            sqlDA.Dispose();

        }
        catch (Exception ex)
        {
            Logger.Log(ex.Message);
            Logger.Log(ex.StackTrace);
        }
        finally
        {
            if (sqlLiteConnection != null && sqlLiteConnection.State == System.Data.ConnectionState.Open)
                sqlLiteConnection.Close();
        }
        return JsonString;
    }
}

0 个答案:

没有答案