1

Closed

Unable to set temporary directory

description

Hi,

I get the following exception in SQLiteConnection.SetTemporaryDirectory:

{"Unable to set temporary directory."}

This happens at least in a Windows 8.1 store application, but also when running a Test Project (x64 platform).

Any advice? Should SQLiteConnection's constructor be passed false for setTemporaryDirectory in some platforms? Since the method is not public, I can't do that on my own at least.

Thanks for advice!
Closed Aug 1, 2014 at 6:45 PM by BeatriceO

comments

thpitsch wrote Jul 16, 2014 at 12:16 PM

I have the same problem in my Universal Project only in the Windows 8.1 Store project. In Windows Phone 8.1 my code works perfect.

This is my 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");
    ...
    }
}
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?

thpitsch wrote Jul 17, 2014 at 4:02 AM

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.

leotilli wrote Jul 18, 2014 at 3:52 PM

Hi @eptanska,

I haven't been able to reproduce this issue; I've tried with both the test solution in the source code, and a new Grid App for Windows Apps (8.1), calling some test code in ItemView_ItemClick event.

On the Grid App, I first configured it to be for x64 Platform, and then added the SQLitePCL Nuget Package, which added and correctly resolved three references: Microsoft Visual C++ 2013 Runtime Package for Windows, SQLite for Windows Runtime (Windows 8.1), SQLitePCL; I've tried this on Visual Studio 2013 Update 2.

Could you verify on the stack trace of the original error, that is pointing to what @thpitsch mentioned: "DLL sqlite3.dll: The specified module could not be found"

Could you verify that the previously mentioned references are resolved correctly on your project, when targeting x64 platform. Have you tried manually removing and re-adding them?

Regards

liu428zhao wrote Oct 24, 2014 at 4:17 AM

i have got the same exception,anyone can tell me how to fix it,thanks a lot.

liu428zhao wrote Oct 24, 2014 at 4:41 AM

This ia stacktrace,as follow:
at SQLitePCL.SQLiteConnection.SetTemporaryDirectory()
at SQLitePCL.SQLiteConnection..ctor(String fileName, Boolean setTemporaryDirectory)
at SQLitePCL.SQLiteConnection..ctor(String fileName)
at eBest.Supervisor.Shared.SQLite.SQLiteAdapter.get_Connection()
at eBest.Supervisor.Shared.SQLite.SQLiteAdapter.Query(String sql, Object[] bindParams, Boolean isThrow)
at eBest.Supervisor.Shared.Sync.SyncConfig.LoadConfig()
at eBest.Supervisor.Shared.Utility.AppLaunch.InitUserCodePwd()
at eBest.Supervisor.Shared.Utility.AppLaunch.Run()
at eBest.Supervisor.WindowsStore.App..ctor()
at eBest.Supervisor.WindowsStore.Program.<Main>b__0(ApplicationInitializationCallbackParams p)

liu428zhao wrote Oct 24, 2014 at 4:42 AM

@BeatriceO