title: SQLite Exception in Windows Store App
body: <p>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.</p>
  
  <pre><code>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");
      ...
      }
  }
  </code></pre>
  
  <p>The exception {"Unable to set temporary directory."} occurs at the last shown line of code, details are this:</p>
  
  <pre><code>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&amp; db)
                   at SQLitePCL.SQLite3Provider.Sqlite3Open(IntPtr filename, IntPtr&amp; db)
                   at SQLitePCL.SQLiteConnection..ctor(String fileName, Boolean setTemporaryDirectory)
              InnerException: 
  </code></pre>
  
  <p>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).</p>
  
  <p>References to SQLite for Windows Runtime (Windows 8.1) (Version 3.8.5.0) and SQLitePCL (v4.0.30319) are properly set.</p>
  
  <p>Any idea what to do?</p>