SQLite Exception in Windows Store App
c#, sqlite, windows-phone-8.1, windows-store-apps
Solution
Even if I had done it several times already, I deleted the reference for Windows Runtime (Windows 8.1) again. But this time I have deleted the reference for Microsoft Visual C++ 2013 Runtime Package for Windows also. After I had both added again, the problem was gone.
Problem
In my Universal App for Windows 8.1 (Store) and Windows Phone 8.1 I have an exception at opening a data base only in the Store App. The code is shared for both, and for Windows Phone it is working. ``` 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"); ... } } ``` The exception {"Unable to set temporary directory."} occurs at the last shown line of code, details are this: ``` 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" is pointing to the problem. I've checked the path "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1\ExtensionSDKs\SQLite.WinRT81\3.8.5\" and found that DLL in all configurations (ARM, x64, x86). References to SQLite for Windows Runtime (Windows 8.1) (Version 3.8.5.0) and SQLitePCL (v4.0.30319) are properly set. Any idea what to do?