samedi 27 février 2016

Using SQLiteAsyncConnection throwing a MissingMethodException

First time using SQLite, opted for SQLite.net-pcl,

I have a PCL library, that I consume from my UWP app, my PCL library has the DBContext class :

public NewspaperDataContext(ISQLitePlatform sqLitePlatform, string applicationPath, string dataBaseName)
{
     _sqlConnection = new SQLiteAsyncConnection(()=> new SQLiteConnectionWithLock(sqLitePlatform, 
     new SQLite.Net.SQLiteConnectionString(Path.Combine(applicationPath, dataBaseName), storeDateTimeAsTicks: false)));

     CreateTableAsync(_sqlConnection, typeof(Article)).Result.Wait();
     CreateTableAsync(_sqlConnection, typeof(Author)).Result.Wait();
     CreateTableAsync(_sqlConnection, typeof(Category)).Result.Wait();
     CreateTableAsync(_sqlConnection, typeof(Group)).Result.Wait();

     var c = _sqlConnection.Table<Article>();
}

private async Task<Task> CreateTableAsync(SQLiteAsyncConnection asyncConnection, Type table)
{
     return asyncConnection.CreateTableAsync<Author>().ContinueWith((results) =>
     {
           Debug.WriteLine(!results.IsFaulted
           ? $"Error where creating the {nameof(table)} table !!"
           : $"Table {nameof(table)} created sucessfully!");
     });
}

I call the NewspaperDataContext from my UWP app like this :

private async void MainPage_OnLoaded(object sender, RoutedEventArgs e)
{            
    var n = new NewspaperDataContext(new SQLitePlatformWinRT(), ApplicationData.Current.LocalFolder.Path, "LiberteDB");
}

In the NewspaperDataContext constructor at the line :

var c = _sqlConnection.Table<Article>();

A strange MissingMethodException is thrown saying :

An exception of type 'System.MissingMethodException' occurred in SQLite.Net.Async.dll but was not handled in user code

Additional information: Method not found: 'Void SQLite.Net.SQLiteConnectionString..ctor(System.String, Boolean, SQLite.Net.IBlobSerializer, SQLite.Net.IContractResolver)'.

Couldn't find anything related to this error in the internet, please can someone help.

Aucun commentaire:

Enregistrer un commentaire