0
votes

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.

1
This is interesting, i have VS2013 Update 4 too. But re-installing Windows and VS is not feasible. Also waiting for Update 5 is not feasible either since the project can't move forward without the database code. Also using other wrappers like SQLite-Net is not good for me because it is an ORM and i have to create classes that map to tables which is not a good solution for the database relations that i have.MrCSharp

1 Answers

1
votes

So i managed to fix this issue. It appears it was caused by the Visual Studio IDE not registering WinMD types and causes the TypeLoadException at Runtime. Downloading Visual Studio Update 5 RC (Release Candidate) will fix the issue. Updating the IDE to Update 5 should take around 30 minutes depending on your internet speed. The RC version is very stable and it is working as it should so i don't believe it will cause any issues with your current projects.