From 67ce81ded8647270668989b4e3e37a27770d4ff8 Mon Sep 17 00:00:00 2001 From: Seraphima Zykova Date: Mon, 26 Jun 2023 17:19:44 +0200 Subject: [PATCH] [Peek] Handle crash when opening app for Internet shortcuts (#26680) * null check * launch uri --- src/modules/peek/Peek.UI/Views/TitleBar.xaml.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/peek/Peek.UI/Views/TitleBar.xaml.cs b/src/modules/peek/Peek.UI/Views/TitleBar.xaml.cs index 400db5670f..bf3c36cbea 100644 --- a/src/modules/peek/Peek.UI/Views/TitleBar.xaml.cs +++ b/src/modules/peek/Peek.UI/Views/TitleBar.xaml.cs @@ -142,7 +142,14 @@ namespace Peek.UI.Views PowerToysTelemetry.Log.WriteEvent(new OpenWithEvent() { App = DefaultAppName ?? string.Empty }); - if (string.IsNullOrEmpty(DefaultAppName)) + // StorageFile objects can't represent files that are ".lnk", ".url", or ".wsh" file types. + // https://learn.microsoft.com/en-us/uwp/api/windows.storage.storagefile?view=winrt-22621 + if (storageFile == null) + { + options.DisplayApplicationPicker = true; + await Launcher.LaunchUriAsync(new Uri(Item.Path), options); + } + else if (string.IsNullOrEmpty(DefaultAppName)) { // If there's no default app found, open the App picker options.DisplayApplicationPicker = true;