SQLiteConnection.CreateTable<>()抛出SEHException(Windows IoT& Raspberry Pi)

时间:2017-04-30 02:35:25

标签: sqlite raspberry-pi3 windows-iot-core-10

我正在尝试使用以下代码连接并使用SQLite数据库:

private SQLiteConnection con;
    //private TableQuery<Reading> readings;
    private TableQuery<Setting> settings;
    private double radius, height, totalVolume, maxLitres;
    public void Run(IBackgroundTaskInstance taskInstance)
    {
        BackgroundTaskDeferral deferral = taskInstance.GetDeferral();

        string path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
        con = new SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path);

        //Createing table if they already don't exist
        con.CreateTable<Setting>();
        con.CreateTable<Reading>();

        settings = con.Table<Setting>();
        //readings = con.Table<Reading>();

        con.Insert(new Setting() { name = "radius", value = 0.8128 });
        con.Insert(new Setting() { name = "height", value = 1.6256 });

        radius = getSetting(settings, "radius").value;
        height = getSetting(settings, "height").value;

        totalVolume = Math.PI * Math.Pow(radius, 2) * height;
        maxLitres = totalVolume * 1000;

        WebServer server = new WebServer();

        //await ThreadPool.RunAsync(workItem => { server.Start(); });
        server.Start();

    }

public sealed class Setting
    {
        [PrimaryKey, AutoIncrement]
        public int id { get; set; }
        public string name { get; set; }
        public double value { get; set; }

    }
  

抛出异常:mscorlib.ni.dll中的'System.Runtime.InteropServices.SEHException'

在此行中出现此错误:

con.CreateTable<Setting>();

它正在运作,但现在却没有。非常令人沮丧。

0 个答案:

没有答案