sqlite-net-pcl SqliteAsyncConnection.CreateTableAsync<T> throws System.MissingMethodException
Asked Answered
M

4

7

I am trying to create a table using the latest version of sqlite-net-pcl nuget package

var db = new SQLiteAsyncConnection("data.db");
await db.CreateTableAsync<Site>();

The CreateTableAsync call throws the following exception:

System.MissingMethodException: 'Method not found: 'System.String SQLitePCL.raw.sqlite3_column_name(SQLitePCL.sqlite3_stmt, Int32)'.'

Here is the Site class

public class Site
{
    [PrimaryKey, AutoIncrement]
    public int Id { get; set; }

    public String Name;
    public String PriceCssSelector;
    public String URLRegex;

    public Site()
    {
    }
}

I tried downgrading to the latest stable version of sqlite-net-pcl package.

Mojica answered 1/9, 2019 at 9:29 Comment(3)
Did you do a clean build?Bonsai
@Bonsai Yes. When I downgrade the exception changes to FileLoadException: Could not load file or assembly 'SQLitePCLRaw.batteries_v2, Version=1.1.11.121, Culture=neutral, PublicKeyToken=8226ea5df37bcae9' or one of its dependencies.Mojica
I suspect the version is wrong. For testing create a simple new project just adding the sqllite library and see if you get the same error. You can then edit your .proj file and copy the version number from the test project .proj file. This usually works.Bonsai
T
6

In my case the problem was Microsoft.AppCenter and Microsoft.Appcenter.Distribute. Those packages bring in an incompatible SQLite version and downgrading/removing them solved the problem.

Tonjatonjes answered 21/2, 2020 at 21:18 Comment(0)
M
0

Deleting the app.config file in my project seems to have solved the problem.

Mojica answered 1/9, 2019 at 10:33 Comment(0)
R
0

I resolved this error, by creating a fresh new solution and manually copying over all the code & models, then let Visual Studio import all the needed references from Nuget.

Uninstalling, reinstalling or removing packages from Nuget in my old/previous solution/project did not help/work.

Apparently lingering or conflicting references from previous Nuget packages is the problem so starting fresh is the only thing that worked for me.

See this link as well:

similar StackOverFlow post for 'System.MissingMethodException: Method not found?'

Roehm answered 31/10, 2019 at 19:36 Comment(0)
D
0

I have stumbled across this error after installing sqlite-net-pcl (for toying with SQLite) and after that I have installed Microsoft.Azure.Mobile.Client.SQLiteStore.

My solution was to uninstall both NuGet packages and install Microsoft.Azure.Mobile.Client.SQLiteStore only which installed the appropriate sqlite-net-pcl version.

Deceptive answered 31/5, 2020 at 15:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.