Search code examples
c#sqlite-net

sqlite3_soft_heap_limit64 in type SQLitePCL.SQLite3Provider_dynamic_cdecl does not have an implementation


I am using the sqlite-net-pcl library in conjunction with Microsoft.Data.Sqlite.Core. It contains all the necessary libraries, but when you run this code:

Code

this is what happens:

Method 'sqlite3_soft_heap_limit64' in type 'SQLitePCL.SQLite3Provider_dynamic_cdecl' from assembly 'SQLitePCLRaw.provider.dynamic_cdecl, Version=2.0.4.976, Culture=neutral, PublicKeyToken=b68184102cba0b3b' does not have an implementation.
Exception has been thrown by the target of an invocation.
The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception.
Exception has been thrown by the target of an invocation.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.TypeInitializationException: The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception.
 ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.TypeLoadException: Method 'sqlite3_soft_heap_limit64' in type 'SQLitePCL.SQLite3Provider_dynamic_cdecl' from assembly 'SQLitePCLRaw.provider.dynamic_cdecl, Version=2.0.4.976, Culture=neutral, PublicKeyToken=b68184102cba0b3b' does not have an implementation.
   at void SQLitePCL.Batteries_V2.DoDynamic_cdecl(string name, int flags)
   at void SQLitePCL.Batteries_V2.Init()
   --- End of inner exception stack trace ---
   at object RuntimeMethodHandle.InvokeMethod(object target, object[] arguments, Signature sig, bool constructor, bool wrapExceptions)
   at object System.Reflection.RuntimeMethodInfo.Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
   at object System.Reflection.MethodBase.Invoke(object obj, object[] parameters)
   at void Microsoft.Data.Sqlite.Utilities.BundleInitializer.Initialize()
   at static Microsoft.Data.Sqlite.SqliteConnection()

I use RageMP but I'm sure it doesn't affect anything. CSProject


Solution

  • In my case, I was using version 3.1.32 of these packages:

    • Microsoft.AspNetCore.Mvc.NewtonsoftJson
    • Microsoft.AspNetCore.Mvc.Testing
    • Microsoft.AspNetCore.TestHost
    • Microsoft.Data.Sqlite.Core

    For Microsoft.Data.Sqlite.Core, I was using version 7.0.3.

    I updated the first packages from 3.1.32 to version 5.0.17, but kept Microsoft.Data.Sqlite.Core at version 7.0.3 and the error started happening.

    I downgraded Microsoft.Data.Sqlite.Core to version 5.0.17, and the error went away - and consequently my integration tests started passing again.