Aravind Belagaje
Aravind Belagaje

Reputation: 406

System.DllNotFoundException for sqlite3

I have installed Microsoft.Data.Sqlite Nuget package of version 1,1,1 (Because i have visual studio 2015 and 2.0.0 is not supported in it). Everything works fine in x86 and x64 but the problem comes for the arm version when i deploy the app th my mobile it throes the following exception

An exception of type 'System.DllNotFoundException' occurred in Microsoft.Data.Sqlite.dll but was not handled in user code

Additional information: Unable to load DLL 'sqlite3': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

This is my stack trace

   at Microsoft.Data.Sqlite.Interop.NativeMethods.Sqlite3_sqlite3.sqlite3_open_v2(IntPtr filename, Sqlite3Handle& ppDb, Int32 flags, IntPtr vfs)
   at Microsoft.Data.Sqlite.Interop.NativeMethods.Sqlite3_sqlite3.open_v2(IntPtr filename, Sqlite3Handle& ppDb, Int32 flags, IntPtr vfs)
   at Microsoft.Data.Sqlite.Interop.NativeMethods.sqlite3_open_v2(String filename, Sqlite3Handle& ppDb, Int32 flags, String vfs)
   at Microsoft.Data.Sqlite.SqliteConnection.Open()
   at Microsoft.Data.Sqlite.Interop.NativeMethods.OnLoad()
   at Microsoft.Data.Sqlite.Interop.NativeMethods.get_Sqlite3()
   at Microsoft.Data.Sqlite.Interop.NativeMethods.sqlite3_open_v2(String filename, Sqlite3Handle& ppDb, Int32 flags, String vfs)
   at Microsoft.Data.Sqlite.SqliteConnection.Open()
   at MyTodoData.functions..ctor()
   at My_Todo.MainPage..ctor()
   at My_Todo.My_Todo_XamlTypeInfo.XamlTypeInfoProvider.Activate_0_MainPage()
   at My_Todo.My_Todo_XamlTypeInfo.XamlUserType.ActivateInstance()

My phone is lumia 640 running 15254.1

Upvotes: 1

Views: 2221

Answers (1)

Aravind Belagaje
Aravind Belagaje

Reputation: 406

Using the line

SqliteEngine.UseWinSqlite3();

or

Microsoft.Data.Sqlite.Internal.SqliteEngine.UseWinSqlite3();

Has solved the issue.

The x86 and x64 versions have built in sqlite3.dll but it is not present in ARM devices.

Newer devices like Lumia 950 or 950xl might have the package but the older device like lumia 640 doesn't have.

According to this Link After Fall creators update you should be able to use SQLite without any extra binaries. My phone had fall creators update but the target version of project was Anniversary Update.

Now it uses the Sqlite engine provided with nuget rather than the System installed one.

Upvotes: 2

Related Questions