Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Adding platform check before invoking dllimport method #2186

Merged
merged 2 commits into from
Mar 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions src/Uno.Extensions.Core/PlatformHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
nickrandolph marked this conversation as resolved.
Show resolved Hide resolved
{
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;
}
}
}
Loading