SQLite exception in Windows Store app

In my universal application for Windows 8.1 (Store) and Windows Phone 8.1, I have an exception when opening a database only in the Store application. The code is common to both, and it works for Windows Phone.

class MemoDB
{
    public static SQLiteConnection conn;

    public MemoDB() { 
        conn = LoadDatabase();
    }

    static private SQLiteConnection LoadDatabase()
    {
       // Get a reference to the SQLite database
       conn = new SQLiteConnection("ct_history.sqlite");
    ...
    }
}

Exception {"Unable to set temporary directory." } occurs in the last displayed line of code, details:

SQLitePCL.SQLiteException was not handled by user code.
  HResult=-2146233088
  Message=Unable to set temporary directory.
  Source=SQLitePCL
  StackTrace:
       at SQLitePCL.SQLiteConnection.SetTemporaryDirectory()
       at SQLitePCL.SQLiteConnection..ctor(String fileName, Boolean setTemporaryDirectory)
       at SQLitePCL.SQLiteConnection..ctor(String fileName)
       at CTDICT.MemoDB.LoadDatabase()
       at CTDICT.MemoDB..ctor()
       at CTDICT.Dictionary..ctor()
       at CTDICT.CTDICT_Windows_XamlTypeInfo.XamlTypeInfoProvider.Activate_8_Dictionary()
       at CTDICT.CTDICT_Windows_XamlTypeInfo.XamlUserType.ActivateInstance()
  InnerException: SQLitePCL.SQLiteException
       HResult=-2146233088
       Message=Unable to open the database file: :memory:
       Source=SQLitePCL
       StackTrace:
            at SQLitePCL.SQLiteConnection..ctor(String fileName, Boolean setTemporaryDirectory)
            at SQLitePCL.SQLiteConnection.SetTemporaryDirectory()
       InnerException: System.DllNotFoundException
            HResult=-2146233052
            Message=DLL "sqlite3.dll": The specified module could not be found. (Exception from HRESULT: 0x8007007E) can not be loaded.
            Source=SQLitePCL.Ext
            TypeName=""
            StackTrace:
                 at SQLitePCL.SQLite3Provider.NativeMethods.sqlite3_open(IntPtr filename, IntPtr& db)
                 at SQLitePCL.SQLite3Provider.Sqlite3Open(IntPtr filename, IntPtr& db)
                 at SQLitePCL.SQLiteConnection..ctor(String fileName, Boolean setTemporaryDirectory)
            InnerException: 

It seems to me that "DLL sqlite3.dll: the specified module could not be found" indicates a problem. I checked the path "C: \ Program Files (x86) \ Microsoft SDK \ Windows \ v8.1 \ ExtensionSDKs \ SQLite.WinRT81 \ 3.8.5 \" and found that the DLL was in all configurations (ARM, x64, x86).

Links to SQLite for Windows Runtime (Windows 8.1) (version 3.8.5.0) and SQLitePCL (v4.0.30319) are correctly installed.

Any idea what to do?

+4
1

, Windows Runtime (Windows 8.1). Microsoft Visual ++ 2013 Runtime Package Windows. , , .

+5

Source: https://habr.com/ru/post/1548592/


All Articles