You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AppInstance.FindOrRegisterForKey throws ArgumentException: The parameter is incorrect #5694
area-LifecycleTopics related to the AppLifecycle, providing lifecycle management for WindowsAppSDK appsneeds-area-owner-attentionThe issue has been routed to the owning team for review.
While trying to track down crashes, I put var keyInstance = AppInstance.FindOrRegisterForKey("main"); in a try-catch and found that it's throwing an ArgumentException (with message "The parameter is incorrect.\r\n\r\nThe parameter is incorrect") for some of my users.
Steps to reproduce the bug
class Program
{
[STAThread]
static void Main()
{
try
{
var keyInstance = AppInstance.FindOrRegisterForKey("main");
if (keyInstance.IsCurrent)
{
keyInstance.Activated += (_, _) => App.HandleAppActivation();
Application.Start(p =>
{
var context = new DispatcherQueueSynchronizationContext(DispatcherQueue.GetForCurrentThread());
SynchronizationContext.SetSynchronizationContext(context);
_ = new App();
});
}
else { keyInstance.RedirectActivationToAsync(AppInstance.GetCurrent().GetActivatedEventArgs()).GetAwaiter().GetResult(); }
}
catch (Exception ex) { **log error** }
}
}
Thank you for your contribution. There are other function calls within the try block. To verify that the exception is specifically caused by AppInstance.FindOrRegisterForKey("main"), could you please try isolating that call and see if the issue still reproduces?
Sorry, I forgot to add the stack trace that was being logged:
at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|38_0(Int32) + 0x42
at ABI.Microsoft.Windows.AppLifecycle.IAppInstanceStaticsMethods.FindOrRegisterForKey(IObjectReference, String) + 0xe2
at MyApp.Program.Main() + 0x21
System.Runtime.InteropServices.COMException (0x8000FFFF): Catastrophic failure
Catastrophic failure
at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|38_0(Int32) + 0x42
at ABI.Microsoft.Windows.AppLifecycle.IAppInstanceStaticsMethods.FindOrRegisterForKey(IObjectReference, String) + 0xe2
at MyApp.Program.Main() + 0x21
System.Runtime.InteropServices.COMException (0x80040154): Unexpected HRESULT has been returned from a call to a COM component.
at WinRT.ActivationFactory.ManifestFreeGet(String, Guid, Int32) + 0x12a
at WinRT.ActivationFactory.Get(String, Guid) + 0x4c
at Microsoft.Windows.AppLifecycle.AppInstance.get__objRef_global__Microsoft_Windows_AppLifecycle_IAppInstanceStatics() + 0x3e
at MyApp.Program.Main() + 0x12
System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.
at WinRT.ActivationFactory.ManifestFreeGet(String, Guid, Int32) + 0x12a
at WinRT.ActivationFactory.Get(String, Guid) + 0x4c
at Microsoft.Windows.AppLifecycle.AppInstance.get__objRef_global__Microsoft_Windows_AppLifecycle_IAppInstanceStatics() + 0x3e
at MyApp.Program.Main() + 0x12
area-LifecycleTopics related to the AppLifecycle, providing lifecycle management for WindowsAppSDK appsneeds-area-owner-attentionThe issue has been routed to the owning team for review.
Activity
ssparach commentedon Aug 7, 2025
Thank you for your contribution. There are other function calls within the try block. To verify that the exception is specifically caused by
AppInstance.FindOrRegisterForKey("main"), could you please try isolating that call and see if the issue still reproduces?tipa commentedon Aug 7, 2025
Sorry, I forgot to add the stack trace that was being logged:
tipa commentedon Aug 8, 2025
I collected some more stack traces:
tipa commentedon Sep 22, 2025
Another one:
benstevens48 commentedon Nov 5, 2026
I am also seeing intermittent crashes when calling AppInstance.FindOrRegisterForKey with code like this.
Even with the latest WindowsAppSdk 2.6.5. On Windows 11 26H2.