{"record":{"id":"34627d1e1a499b7c","repo":"dotnet/maui","slug":"activateapplication-failed-hresult-0x-0-x8","errorCode":null,"errorMessage":"ActivateApplication failed (HRESULT=0x{0:X8})","messagePattern":"ActivateApplication failed \\(HRESULT=0x(.+?)\\)","errorType":"exception","errorClass":"System.ComponentModel.Win32Exception","httpStatus":null,"severity":"error","filePath":"eng/devices/Run-PackagedAppAndWait.ps1","lineNumber":48,"sourceCode":"using System.Runtime.InteropServices;\n[ComImport, Guid(\"2e941141-7f97-4756-ba1d-9decde894a3d\"),\n InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]\npublic interface IApplicationActivationManager {\n    int ActivateApplication([In, MarshalAs(UnmanagedType.LPWStr)] string appUserModelId,\n        [In, MarshalAs(UnmanagedType.LPWStr)] string arguments,\n        [In] uint options,\n        [Out] out uint processId);\n}\n[ComImport, Guid(\"45BA127D-10A8-46EA-8AB7-56EA9078943C\")]\npublic class ApplicationActivationManager { }\n\npublic static class PackagedAppLauncher {\n    public static uint Launch(string aumid, string arguments) {\n        var mgr = (IApplicationActivationManager)(new ApplicationActivationManager());\n        uint pid;\n        int hr = mgr.ActivateApplication(aumid, arguments ?? string.Empty, 0, out pid);\n        if (hr != 0) {\n            throw new System.ComponentModel.Win32Exception(hr,\n                string.Format(\"ActivateApplication failed (HRESULT=0x{0:X8})\", hr));\n        }\n        return pid;\n    }\n}\n\"@ -ErrorAction SilentlyContinue | Out-Null\n\n[uint32]$procId = 0\ntry {\n    $procId = [PackagedAppLauncher]::Launch($aumid, $AppArguments)\n} catch {\n    Write-Error \"ActivateApplication threw: $_\"\n    exit 3\n}\nif ($procId -eq 0) {\n    Write-Error \"ActivateApplication returned PID 0\"\n    exit 3\n}","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/eng/devices/Run-PackagedAppAndWait.ps1#L30-L66","documentation":"Thrown by PackagedAppLauncher.Launch when the COM call IApplicationActivationManager.ActivateApplication returns a non-zero HRESULT, wrapped as a Win32Exception. This means Windows could not activate (launch) the packaged app identified by the given Application User Model ID (AUMID).","triggerScenarios":"mgr.ActivateApplication(aumid, arguments, 0, out pid) returns hr != 0. Common HRESULTs include 0x80073CFC (app not registered/installed), 0x80070002 (file not found), or registration/policy errors.","commonSituations":"The AUMID is wrong or the app package is not installed/registered for the current user; the packaged app was uninstalled or its registration is corrupt; running on a non-packaged build; the app requires a runtime/dependency not present.","solutions":["Confirm the package is installed and registered: `Get-AppxPackage <packageFullName>` and check the AUMID via `Get-StartApps` or the manifest.","Re-register or reinstall the appx/msix package if registration is corrupt: `Add-AppxPackage -Register ...AppxManifest.xml`.","Decode the HRESULT (e.g. 0x80073CFC = APPMODEL_ERROR_NO_PACKAGE) to pinpoint the cause.","Verify the AUMID string passed matches the package's Application Id from its AppxManifest."],"exampleFix":"# before\n$procId = [PackagedAppLauncher]::Launch($wrongAumid, $AppArguments)\n# after\n# confirm correct AUMID first\nGet-AppxPackage *TestCases* | Select-Object PackageFamilyName\n$procId = [PackagedAppLauncher]::Launch(\"$correctPackageFamilyName!App\", $AppArguments)","handlingStrategy":"validation","validationCode":"# Validate package registration + AUMID before launching\n$pkg = Get-AppxPackage -Name $packageName\nif (-not $pkg) { throw \"Package '$packageName' is not installed/registered.\" }\n$aumid = \"$($pkg.PackageFamilyName)!$applicationId\"\nif (-not (Get-StartApps | Where-Object { $_.AppID -eq $aumid })) { throw \"AUMID '$aumid' not found.\" }","typeGuard":null,"tryCatchPattern":"try {\n    $procId = [PackagedAppLauncher]::Launch($aumid, $AppArguments)\n} catch [System.ComponentModel.Win32Exception] {\n    Write-Error \"Launch failed HRESULT=0x$($_.Exception.NativeErrorCode.ToString('X8')) for AUMID '$aumid'\"\n    throw\n}","preventionTips":["Always derive the AUMID from PackageFamilyName + Application Id rather than hardcoding.","Confirm Get-AppxPackage returns the package before attempting activation.","Log the HRESULT so failures are diagnosable; re-register the package on registration errors."],"tags":["windows","packaged-app","com","win32","msix","aumid"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}