在 Windows Phone 8.1 应用程序中连接到 SQLite 数据库时出错
Error connecting to SQLite database in Windows Phone 8.1 application
我正在使用 Xamarin Forms 开发应用程序。我需要数据库,所以我通过 NuGet 包管理器安装了 Frank A.Krueger 的 sqlite-net-pcl
。我尝试在 PCL 项目中建立连接:
ISQLiteHelper sqlLiteHelper = DependencyService.Get<ISQLiteHelper>();
string pathToDatabaseFile = sqlLiteHelper.GetLocalDatabaseFilePath(databaseFilename);
this.database = new SQLiteConnection(pathToDatabaseFile);
但是我遇到了一个例外。
"Unable to load DLL 'e_sqlite3': The specified module could not be
found. (Exception from HRESULT: 0x8007007E)"
我按照一些答案下载并安装了 sqlite-wp81-winrt-3180000.vsix
然后我将以下参考添加到我的 WinPhone 8.1 项目中:参考管理器 -> Windows Phone 8.1 -> Extensions -> SQLite for Windows 8.1 但它对我没有帮助。我得到了同样的错误。
我将目标平台更改为 x86。对于任何 CPU 我得到一个错误:
"Any CPU" is not supported by the referenced SDK "Microsoft.VCLibs,
Version=12.0". Please consider changing the targeted processor
architecture of your project (in Visual Studio this can be done
through the Configuration Manager) to one of the architectures
supported by the SDK: "x86, ARM". App1.WinPhone
如果我像我的 PC 那样将目标平台更改为 x64,就会出现该错误。
"X64" is not supported by the referenced SDK "Microsoft.VCLibs,
Version=12.0". Please consider changing the targeted processor
architecture of your project (in Visual Studio this can be done
through the Configuration Manager) to one of the architectures
supported by the SDK: "x86, ARM". App1.WinPhone
"X64" is not supported by the referenced SDK "SQLite.WP81,
Version=3.18.0". Please consider changing the targeted processor
architecture of your project (in Visual Studio this can be done
through the Configuration Manager) to one of the architectures
supported by the SDK: "x86, ARM". App1.WinPhone
解决方案: 您可以使用 Oustein Krog、Frank Krueger、Tim Heuer 的 SQLite.Net-PCL
而不是 sqlite-net-pcl
。
集合的创建将如下所示:
this.database = new SQLiteConnection(databaseFilename);
我正在使用 Xamarin Forms 开发应用程序。我需要数据库,所以我通过 NuGet 包管理器安装了 Frank A.Krueger 的 sqlite-net-pcl
。我尝试在 PCL 项目中建立连接:
ISQLiteHelper sqlLiteHelper = DependencyService.Get<ISQLiteHelper>();
string pathToDatabaseFile = sqlLiteHelper.GetLocalDatabaseFilePath(databaseFilename);
this.database = new SQLiteConnection(pathToDatabaseFile);
但是我遇到了一个例外。
"Unable to load DLL 'e_sqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"
我按照一些答案下载并安装了 sqlite-wp81-winrt-3180000.vsix
然后我将以下参考添加到我的 WinPhone 8.1 项目中:参考管理器 -> Windows Phone 8.1 -> Extensions -> SQLite for Windows 8.1 但它对我没有帮助。我得到了同样的错误。
我将目标平台更改为 x86。对于任何 CPU 我得到一个错误:
"Any CPU" is not supported by the referenced SDK "Microsoft.VCLibs, Version=12.0". Please consider changing the targeted processor architecture of your project (in Visual Studio this can be done through the Configuration Manager) to one of the architectures supported by the SDK: "x86, ARM". App1.WinPhone
如果我像我的 PC 那样将目标平台更改为 x64,就会出现该错误。
"X64" is not supported by the referenced SDK "Microsoft.VCLibs, Version=12.0". Please consider changing the targeted processor architecture of your project (in Visual Studio this can be done through the Configuration Manager) to one of the architectures supported by the SDK: "x86, ARM". App1.WinPhone
"X64" is not supported by the referenced SDK "SQLite.WP81, Version=3.18.0". Please consider changing the targeted processor architecture of your project (in Visual Studio this can be done through the Configuration Manager) to one of the architectures supported by the SDK: "x86, ARM". App1.WinPhone
解决方案: 您可以使用 Oustein Krog、Frank Krueger、Tim Heuer 的 SQLite.Net-PCL
而不是 sqlite-net-pcl
。
集合的创建将如下所示:
this.database = new SQLiteConnection(databaseFilename);