Search code examples
vb.netsqlitewindows-runtimevisual-studio-2013windows-8.1

Create table using SQLite in WinRT: BadImageFormatException


I am using Sqlite3 and added referene to my windows store app and trying to create a database as shown below:

C:\Sqlite3>Sqlite3 mydata.db

Next trying to a create table from my codebehind as shown:

 Try
     Dim dbpath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "mydata.db")
       Using db = New SQLite.SQLiteConnection(dbpath)
       ' Create the tables if they don't exist
        db.CreateTable(Of person)()
        db.Commit()
        db.Dispose()
        db.Close()
      End Using
     Dim line = New MessageDialog("Table Created")
     Await line.ShowAsync()
  Catch
End Try

Now it dosen't create any table and get's an exception as shown below

enter image description here

Can anyone say me where am I going wrong?


Solution

  • From: What causes System.BadImageFormatException when constructing System.Data.SQLite.SQLiteConnection

    SqlLite contains unmanaged code, you can't run it on a 64-bit operating system unless you deploy the 64-bit version. Quick fix: Project + Properties, Build tab, Platform Target = x86.