mardi 30 juin 2015

Getting TypeLoadException when using Sqlite-WinRT

i am developing a Windows Phone 8.1 app (WinRT) and i want to add support for SQLite. I have added the SQLite for Windows Phone extension to the project and also added the SQLite-WinRT wrapper. I also changed the build configuration to x86 so it can run in the emulator. My problem is: When i try to open a connection to a database file (either create or just open) i get a TypeLoadException. My code to open the connection is like this:

using (var db = new SQLiteWinRT.Database(ApplicationData.Current.TemporaryFolder, "Database.db"))
        {
            await db.OpenAsync(SqliteOpenMode.OpenOrCreateReadWrite);
            await db.ExecuteStatementAsync(@"create table if not exists MyTable ( ID integer not null primary key autoincrement, Name varchar(150) not null);");

            await db.ExecuteStatementAsync(@"insert into MyTable (Name) values ('Rafael');");
        }

When the first line is executed i get this error:

enter image description here

Here is a list of references in my project:

enter image description here

Any help is appreciated. Thank you all.

Aucun commentaire:

Enregistrer un commentaire