From 3862115053bb9e265b3c7046ab4b9442284a32b1 Mon Sep 17 00:00:00 2001 From: Nick Randolph Date: Tue, 27 Feb 2024 03:34:23 +1100 Subject: [PATCH 1/2] fix: Adding platform check before invoking dllimport method --- src/Uno.Extensions.Core/PlatformHelper.cs | 31 +++++++++++++---------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/Uno.Extensions.Core/PlatformHelper.cs b/src/Uno.Extensions.Core/PlatformHelper.cs index 0b31ad186a..7a62d8f4b4 100644 --- a/src/Uno.Extensions.Core/PlatformHelper.cs +++ b/src/Uno.Extensions.Core/PlatformHelper.cs @@ -74,21 +74,26 @@ private static void EnsureInitialized() || RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")); // If wasm, then can assume app isn't packaged, so skip this check - if (!IsWebAssembly) + if (!IsWebAssembly && RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - try - { - // Application is MSIX packaged if it has an identity: https://learn.microsoft.com/en-us/windows/msix/detect-package-identity - int length = 0; - var sb = new System.Text.StringBuilder(0); - int result = GetCurrentPackageFullName(ref length, sb); - _isAppPackaged = result != AppModelErrorNoPackage; - } - catch - { - _isAppPackaged = false; - } + _isAppPackaged = IsWindowsAppPackaged(); } } } + + private static bool IsWindowsAppPackaged() + { + try + { + // Application is MSIX packaged if it has an identity: https://learn.microsoft.com/en-us/windows/msix/detect-package-identity + int length = 0; + var sb = new System.Text.StringBuilder(0); + int result = GetCurrentPackageFullName(ref length, sb); + return result != AppModelErrorNoPackage; + } + catch + { + return false; + } + } } From 5b7d0c9353b44c3d31a5086400d0662c7071c4ae Mon Sep 17 00:00:00 2001 From: Nick Randolph Date: Tue, 27 Feb 2024 13:15:31 +1100 Subject: [PATCH 2/2] chore: Tidy up MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jérôme Laban --- src/Uno.Extensions.Core/PlatformHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Uno.Extensions.Core/PlatformHelper.cs b/src/Uno.Extensions.Core/PlatformHelper.cs index 7a62d8f4b4..4183f46c03 100644 --- a/src/Uno.Extensions.Core/PlatformHelper.cs +++ b/src/Uno.Extensions.Core/PlatformHelper.cs @@ -74,7 +74,7 @@ private static void EnsureInitialized() || RuntimeInformation.IsOSPlatform(OSPlatform.Create("BROWSER")); // If wasm, then can assume app isn't packaged, so skip this check - if (!IsWebAssembly && RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { _isAppPackaged = IsWindowsAppPackaged(); }