Skip to content

Commit

Permalink
Microsoft.Data.Sqlite: Also try the .NET 5+ ApplicationData API
Browse files Browse the repository at this point in the history
Fixes #24213
  • Loading branch information
bricelam committed Sep 22, 2021
1 parent 2b2f3a3 commit 1c74909
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public static string? LocalFolderPath
try
{
return Type.GetType("Windows.Storage.ApplicationData, Windows, ContentType=WindowsRuntime")
?? Type.GetType("Windows.Storage.ApplicationData, Microsoft.Windows.SDK.NET")
?.GetRuntimeProperty("Current")!.GetValue(null);
}
catch
Expand Down
5 changes: 3 additions & 2 deletions src/Microsoft.Data.Sqlite.Core/Utilities/BundleInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Diagnostics;
using System.Reflection;
using static SQLitePCL.raw;

Expand Down Expand Up @@ -34,12 +35,12 @@ public static void Initialize()
var rc = sqlite3_win32_set_directory(
SQLITE_WIN32_DATA_DIRECTORY_TYPE,
ApplicationDataHelper.LocalFolderPath);
SqliteException.ThrowExceptionForRC(rc, db: null);
Debug.Assert(rc == SQLITE_OK);

rc = sqlite3_win32_set_directory(
SQLITE_WIN32_TEMP_DIRECTORY_TYPE,
ApplicationDataHelper.TemporaryFolderPath);
SqliteException.ThrowExceptionForRC(rc, db: null);
Debug.Assert(rc == SQLITE_OK);
}
}
}
Expand Down

0 comments on commit 1c74909

Please sign in to comment.