Exception when using SQLite in WinRT app

谁都会走 提交于 2019-11-29 14:37:37

Your project has its build mode currently set to Any CPU, what is the default. Because the SqLite assembly is not build as AnyCPU you need to set your build mode to X86 and add the X86 SqLite reference.

When deploying your app you also need to create 3 packages instead of 1 AnyCPU package.

Because your project is AnyCPU you get the error message when trying to add the x86, x86 is not valid for AnyCPU.


UPDATE

I tried to replicate your problem. I installed the SQLite for Windows Runtime for Visual Studio Ultimate 2012, after that I created a Windows Store Project, then added the SqLite reference after that I added sqlite-net and last I added your code for DB creation.

I modified the code a little bit (path & tables). But my code gives no error at all.

I did not need to reference the SqLite assemblies myself. Because by installing the extension into Visual Studio you get the reference in your extension list (still need to select it, just not add the dlls):

But still like I said in my first answer, you need to set your build mode to something else than 'Any CPU'

My example is on my skydrive (when testing set configuration to x86).


UPDATE 2

Db path:

var dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
var db = new SQLite.SQLiteConnection(dbPath);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!