4

こんにちは、SQLite.cs と SQLiteAsync.cs の 2 つの cs ファイルが付属する sqlite-net nuget パッケージをインストールしました。

SQLite.csSQLite3次のメソッドを含むクラスが呼び出されます。

[DllImport("sqlite3", EntryPoint = "sqlite3_win32_set_directory", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
public static extern int SetDirectory(uint directoryType, string directoryPath);

SQLiteConnectionコンストラクターには次のコードがあることがわかります。

#if NETFX_CORE
         SQLite3.SetDirectory(/*temp directory type*/2, Windows.Storage.ApplicationData.Current.TemporaryFolder.Path);
#endif

しかし、なぜですか?新しい SQLiteConnection が作成されるたびに設定する必要があるのはなぜですか? AccessViolationExceptionsこの行で散発的になるようです。

アップデート

このメソッドのドキュメントを見つけましたが、まだ TempDirectory の目的を理解していません。そこには何が書かれていますか?

/*
** This function sets the data directory or the temporary directory based on
** the provided arguments.  The type argument must be 1 in order to set the
** data directory or 2 in order to set the temporary directory.  The zValue
** argument is the name of the directory to use.  The return value will be
** SQLITE_OK if successful.
*/
4

1 に答える 1