Exception when using SQLite in WinRT app

前端 未结 1 786
独厮守ぢ
独厮守ぢ 2020-12-21 04:20

I\'m building a Windows 8 app, and now I want to use SQLite for this app. I installed SQLite for Windows Runtime through the Visual Studio 2013 extension manage

相关标签:
1条回答
  • 2020-12-21 04:31

    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):

    add reference

    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);
    
    0 讨论(0)
提交回复
热议问题