【发布时间】:2014-07-04 02:07:32
【问题描述】:
我正在尝试在 Visual Studio 2013 上的 WinRT 8.1 上使用 SQLite 进行编程。我使用 WinRT 8.1 VSIX 安装了 SQLite,并为 Windows Phone 8.1 安装了相同的 SQLite,还从 nuget 加载了sqlite-net。
我用得到以下错误:
An exception of type 'System.BadImageFormatException' occurred in TimeTableAPP.Windows.exe but was not handled in user code
从这两行代码:
SQLiteAsyncConnection cneu = new SQLiteAsyncConnection("newDB.db");
await cneu.CreateTableAsync<TestTable>();
与
相同var conn = new SQLiteAsyncConnection(System.IO.Path.Combine(Windows.ApplicationModel.Package.Current.InstalledLocation.Path, "newDB.db"));
await cneu.CreateTableAsync<TestTable>();
使用测试表
[Table("TestTable")]
public class TestTable
{
[PrimaryKey, AutoIncrement]
public long Id { get; set; }
public string nomnomnom { get; set; }
}
这个问题似乎经常发生,通常通过将平台目标设置为 x86 来解决。如您所见,我这样做了:
我不知道该尝试什么了。我对 VC2013 安装进行了修复,卸载并重新安装了 VSIX,并为共享的 Windows 8.1 和 Windows Phone 8.1 创建了一个项目,Windows Phone 没有触发错误,但 Windows Store App 使用相同的代码触发了错误。
【问题讨论】:
-
你能用这个代替吗? nuget.org/packages/System.Data.SQLite
-
我不习惯nuget,当我复制粘贴命令时,它给了我一个成功的回报:安装'System.Data.SQLite 1.0.93.0'。成功安装“System.Data.SQLite 1.0.93.0”。将“System.Data.SQLite 1.0.93.0”添加到 App2。成功将“System.Data.SQLite 1.0.93.0”添加到 App2。但我不能像以前那样添加
using System.Data.SQLite,也不能添加using SQLite
标签: c# sqlite windows-runtime visual-studio-2013