Forum Discussion
Application crash on Windows 10 Enterprise LTSC when using AppInstaller
- Dec 01, 2021
I got it working using the `Microsoft.Windows.SDK.Contracts` NuGet package instead of the approach described above (had to convert from package.config to PackageReference)
https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/desktop-to-uwp-enhance#earlier-versions-of-net-install-the-microsoftwindowssdkcontracts-nuget-package
Sample codevar packageManager = new PackageManager(); var currentPackage = packageManager.FindPackageForUser(string.Empty, Package.Current.Id.FullName); var result = await currentPackage.CheckUpdateAvailabilityAsync(); if (result.ExtendedError != null) { LogError("Update availability error", result.ExtendedError); } var hasUpdate = (result.Availability == PackageUpdateAvailability.Available); if (hasUpdate) { // there is an update available }
It seems like Windows 10 Enterprise LTSC build 1809 doesn't support checking for updates programmatically.
I followed the description from here https://techcommunity.microsoft.com/t5/windows-dev-appconsult/handling-application-updates-with-app-installer-and-msix-in/ba-p/355389
private async Task CheckForUpdates()
{
var result = await Package.Current.CheckUpdateAvailabilityAsync();
if (result.Availability == PackageUpdateAvailability.Available)
{
MessageBox.Show("There's a new update! Restart your app to install it");
}
}
It crashes the app, even though I have global error handling configured.
After I removed the code and related DLLs, the app installer is working.
- szilarddDec 01, 2021Brass Contributor
I got it working using the `Microsoft.Windows.SDK.Contracts` NuGet package instead of the approach described above (had to convert from package.config to PackageReference)
https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/desktop-to-uwp-enhance#earlier-versions-of-net-install-the-microsoftwindowssdkcontracts-nuget-package
Sample codevar packageManager = new PackageManager(); var currentPackage = packageManager.FindPackageForUser(string.Empty, Package.Current.Id.FullName); var result = await currentPackage.CheckUpdateAvailabilityAsync(); if (result.ExtendedError != null) { LogError("Update availability error", result.ExtendedError); } var hasUpdate = (result.Availability == PackageUpdateAvailability.Available); if (hasUpdate) { // there is an update available }