Skip to content

Commit 0cea53d

Browse files
authored
Fix settings page crash on Windows 10 (#1480)
## Description On Windows 10, it does not seem to load `Microsoft.WindowsAppRuntime.Insights.Resource.dll` and this crash the app. Added a fallback for this. ## Motivation and Context Closes #1477 ## How Has This Been Tested? Manual ## Screenshots (if appropriate): ![image](https://github.com/microsoft/WinUI-Gallery/assets/42881734/70aa186c-4c53-4dce-b989-62dd04c3dcbe) ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change)
1 parent 9537184 commit 0cea53d

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

WinUIGallery/App.xaml.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,19 @@ public static string WinAppSdkRuntimeDetails
5050
{
5151
get
5252
{
53-
// Retrieve Windows App Runtime version info dynamically
54-
var windowsAppRuntimeVersion =
55-
from module in Process.GetCurrentProcess().Modules.OfType<ProcessModule>()
56-
where module.FileName.EndsWith("Microsoft.WindowsAppRuntime.Insights.Resource.dll")
57-
select FileVersionInfo.GetVersionInfo(module.FileName);
58-
return WinAppSdkDetails + ", Windows App Runtime " + windowsAppRuntimeVersion.First().FileVersion;
53+
try
54+
{
55+
// Retrieve Windows App Runtime version info dynamically
56+
var windowsAppRuntimeVersion =
57+
from module in Process.GetCurrentProcess().Modules.OfType<ProcessModule>()
58+
where module.FileName.EndsWith("Microsoft.WindowsAppRuntime.Insights.Resource.dll")
59+
select FileVersionInfo.GetVersionInfo(module.FileName);
60+
return WinAppSdkDetails + ", Windows App Runtime " + windowsAppRuntimeVersion.First().FileVersion;
61+
}
62+
catch
63+
{
64+
return WinAppSdkDetails + $", Windows App Runtime {WASDK.Runtime.Version.Major}.{WASDK.Runtime.Version.Minor}";
65+
}
5966
}
6067
}
6168

0 commit comments

Comments
 (0)