Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# UWP-在本机中编译时出现SQLite问题_C#_Sqlite_Raspberry Pi_Uwp_Iot - Fatal编程技术网

C# UWP-在本机中编译时出现SQLite问题

C# UWP-在本机中编译时出现SQLite问题,c#,sqlite,raspberry-pi,uwp,iot,C#,Sqlite,Raspberry Pi,Uwp,Iot,我在“调试”模式下使用SQLite开发我的应用程序,效果非常好 当我试图“释放”它(编译“本机”)时,问题开始了,看起来UWP不支持反射 我目前正在使用以下软件包: SQLite.Core.UAP SQLite.Net-PCL 例如,如果我尝试这样做: private void CreateDatabase() { var dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "StoredE

我在“调试”模式下使用SQLite开发我的应用程序,效果非常好

当我试图“释放”它(编译“本机”)时,问题开始了,看起来UWP不支持反射

我目前正在使用以下软件包:

SQLite.Core.UAP
SQLite.Net-PCL
例如,如果我尝试这样做:

  private void CreateDatabase()
    {
        var dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "StoredEvents.sqlite");
        SQLiteConnection SQLiteConn = new SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), dbPath, false);

        SQLiteConn.CreateTable<StoredEvents>();            
    }
我应该如何重构代码


我应该使用不同的图书馆吗

我在将应用程序从Silverlight更新到UWP时也遇到了同样的问题。我在某处读到一篇文章(试图找到它,但无法找到),其中说SQLlite for UWP可用于Windows 10部署

以上是VS的扩展。您可以通过工具->>扩展和更新到达那里

下面是我的推荐信的样子

我还注意到您没有关闭db连接。最好在
语句中使用它。您的
CreateTables()
将如下所示

private void CreateDatabase()
{
    var dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "StoredEvents.sqlite");
    using (SQLiteConnection SQLiteConn = new SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), dbPath, false))
    {
        SQLiteConn.CreateTable<StoredEvents>();
    }     
}
private void CreateDatabase()
{
var dbPath=Path.Combine(ApplicationData.Current.LocalFolder.Path,“StoredEvents.sqlite”);
使用(SQLiteConnection SQLiteConn=newsqliteconnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(),dbPath,false))
{
SQLiteConn.CreateTable();
}     
}
private void CreateDatabase()
{
    var dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "StoredEvents.sqlite");
    using (SQLiteConnection SQLiteConn = new SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), dbPath, false))
    {
        SQLiteConn.CreateTable<StoredEvents>();
    }     
}