C# UWP-在本机中编译时出现SQLite问题
我在“调试”模式下使用SQLite开发我的应用程序,效果非常好 当我试图“释放”它(编译“本机”)时,问题开始了,看起来UWP不支持反射 我目前正在使用以下软件包: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.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>();
}
}