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.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
JohnWick
  • 4,929
  • 9
  • 37
  • 74
  • Did you do a clean build? – jdweng Sep 01 '19 at 09:55
  • @jdweng 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. – JohnWick Sep 01 '19 at 09:57
  • 1
    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. – jdweng Sep 01 '19 at 10:15

4 Answers4

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.

MariusKoch
  • 61
  • 1
  • 4
0

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

JohnWick
  • 4,929
  • 9
  • 37
  • 74
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?'

Alex
  • 228
  • 4
  • 8
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.

Alexei - check Codidact
  • 22,016
  • 16
  • 145
  • 164