CommunityToolkit/WindowsCommunityToolkit

SystemInformation helper throws an exception with Unpackaged Windows App SDK projects

Open

#4356 aperta il 31 ott 2021

Vedi su GitHub
 (5 commenti) (1 reazione) (1 assegnatario)C# (1403 fork)batch import
WinUI :diamond_shape_with_a_dot_inside:bug :bug:help wanted

Metriche repository

Star
 (5708 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

Describe the bug

Upon using the SystemInformation class, the following exception is thrown in unpackaged Windows App SDK projects:

image

  • Is this bug a regression in the toolkit? If so, what toolkit version did you last see it work:

Steps to Reproduce

  • Can this be reproduced in the Sample App? (Either in a sample as-is or with new XAML pasted in the editor.) If so, please provide custom XAML or steps to reproduce. If not, let us know why it can't be reproduced (e.g. more complex setup, environment, dependencies, etc...)

Steps to reproduce the behavior:

  1. Create a new Blank Windows App SDK app (Packaged)
  2. Perform the required modifications to the project so it runs unpackaged (https://aka.ms/winui3/unpackaged-apps)
  3. Add the following code in mainwindow.xaml.cs:
        private void myButton_Click(object sender, RoutedEventArgs e)
        {
            myButton.Content = "Clicked";
            SystemInformation info = SystemInformation.Instance;
        }
  1. Install the Windows App SDK runtime if not already installed (https://aka.ms/windowsappsdk/1.0-preview3/msix-installer)
  2. Start the application
  3. Click on the button
  4. The call to SystemInformation.Instance fails

Expected behavior

SystemInformation.Instance doesn't fail and provides a subset of the values that are available without a package identity, or if not possible, throws a more friendly exception.

Environment

NuGet Package(s):

  • CommunityToolkit.WinUI.UI.Controls
  • Microsoft.WindowsAppSDK (1.0.0-preview3)
  • Microsoft.Windows.SDK.BuildTools (10.0.20348.19)

Package Version(s):

7.1.1-preview3

Windows 10 Build Number:

  • Fall Creators Update (16299)
  • April 2018 Update (17134)
  • October 2018 Update (17763)
  • May 2019 Update (18362)
  • May 2020 Update (19041)
  • Insider Build (22000.282)

App min and target version:

  • Fall Creators Update (16299)
  • April 2018 Update (17134)
  • October 2018 Update (17763)
  • May 2019 Update (18362)
  • May 2020 Update (19041)

Device form factor:

  • Desktop
  • Xbox
  • Surface Hub
  • IoT

Visual Studio version:

  • 2022 (17.Preview/17.0.0-pre.7.0+31825.309)

Guida contributor