-1

I want to connect my application with sqlite database but it throw the exception.

An exception of type 'System.BadImageFormatException' occurred in Scrap_Book.Windows.exe but was not handled in user code

Additional information: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

        var dbpath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "scrapbook.sqlite");
        using (var db = new SQLite.SQLiteConnection(dbpath))

Second line throw exception.

I am unable to resolve it. please help me i am new in programming. Thanks in advance.

vikas sharawat
  • 207
  • 1
  • 13

1 Answers1

0

I install sqlite-net package.

@Henk was right, you installed a wrong package for UWP app, what you need is SQLite.Net-PCL package. And for connection, you can code for example like this:

using (var db = new SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), Path.Combine(ApplicationData.Current.LocalFolder.Path, "scrapbook.sqlite")))
{
    //TODO:
}

and don't forget, your project will also need to reference to SQLite for Universal App Platform.

Grace Feng
  • 16,316
  • 2
  • 20
  • 42