AppInstaller Crashing After Calling Process.Start on MSIX file.
Relevant area(s)
WinGet CLI
Relevant command(s)
winget install
Brief description of your issue
App installer is crashing when our C# application programatically launches a downloaded bundle via Process.Start.
AppInstaller.exe crash from event log
Faulting application name: AppInstaller.exe, version: 1.27.420.0, time stamp: 0x69129eb8
Faulting module name: Microsoft.UI.Xaml.dll, version: 3.1.8.0, time stamp: 0x2239de89
Exception code: 0xc000027b
Fault offset: 0x000000000039dce5
Faulting process id: 0x0xB7DC
Faulting application start time: 0x0x1DC53EA27D98003
Faulting application path: C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.27.420.0_x64__8wekyb3d8bbwe\AppInstaller.exe
Faulting module path: C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.8_8000.642.119.0_x64__8wekyb3d8bbwe\Microsoft.UI.Xaml.dll
Report Id: 0866af73-55a3-4486-8244-fa3379c825b7
Faulting package full name: Microsoft.DesktopAppInstaller_1.27.420.0_x64__8wekyb3d8bbwe
Faulting package-relative application ID: App
Right now this bug is preventing us from pushing additional app updates out as it'll cause pain for our clients.
Related response: https://github.com/microsoft/winget-cli/issues/5847#issuecomment-3549930007
I did confirm with my test app that adding a Thread.Sleep after process start seems to work.
Steps to reproduce
This can be reproduced by creating a basic winexe app and attempting to launch a bundle. Please note Process.Start seems to work for a console application but the bug happens for winexe apps.
Net Framework csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net472</TargetFramework>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
</Project>
Program.cs
using System.Diagnostics;
namespace NetFrameworkAppInstallerBug
{
internal class Program
{
static void Main(string[] args)
{
var installerPath = ""; // Set path to msix, msixbundle, or appxbundle on your machine
Process.Start(installerPath);
}
}
}
This also happens in a .Net 8 application.
.Net 8 csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
</Project>
Program.cs
using System.Diagnostics;
using System.IO;
namespace AppInstallerBug
{
internal class Program
{
static void Main(string[] args)
{
var installerPath = ""; // Set path to msix, msixbundle, or appxbundle on your machine
var appxBundleName = Path.GetFileName(installerPath);
var directory = Path.GetDirectoryName(installerPath);
Process p = new Process();
p.StartInfo.WorkingDirectory = string.IsNullOrEmpty(directory) ? Path.GetTempPath() : directory;
p.StartInfo.FileName = appxBundleName;
p.StartInfo.Verb = "Open";
p.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
p.StartInfo.UseShellExecute = true;
p.Start();
}
}
}
Expected behavior
AppInstaller shouldn't crash.
Actual behavior
AppInstaller currently crashes after calling process start on a windows app install. (appxbundle, msix, msixbundle etc)
Environment
My Machine Details
Windows Build: 22631.6060
Windows SDK:
(get-appxpackage microwinappruntime*).packagefullname
Confirm I also experience the same issue; I use a dedicated self-contained exe to install my publisher certificate and then launch the msix file. This results in the same crash of App Installer.
Interestingly, I don't get this behaviour on my development system, nor do users who are installing in a .NET development environment.
var fn = Directory.EnumerateFiles(installDir).First(a => a.Contains(".msix"));
var p = new Process();
p.StartInfo = new ProcessStartInfo() {
FileName = "powershell.exe",
Arguments = $"\"{fn}\"",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
};
p.Start();
await p.WaitForExitAsync();
Running this on Windows build 10.0.19045 Build 19045
Currently having a large impact on the distribution process.
We also get the same behavior that @odskee mentioned, but opening an .AppInstaller file from explorer.exe using Process.Start
My apologies for the delay. We have a new build out that should address this issue. It is in the process of being rolled out to Insiders through Store updates, and you can also download the .msixbundle from the Releases page. Please let me know if this version works for you.
For tracking purposes, I believe this is caused by https://github.com/microsoft/WindowsAppSDK/issues/5481