Skip to content

Lifetime of activation arguments is too short and unclear #6074

@florelis

Description

@florelis

Describe the bug

The activation arguments have a short lifetime, which makes it easy to hit errors when trying to use them. The main issue is that this includes the data in the arguments, so one has to know to copy it out instead of just keeping a reference to it.

The documentation for AppInstance.GetActivatedEventArgs mentions that

for packaged apps, this method will only return the arguments the first time it is called in an app. So, you should call it as early as possible during activation, as the arguments may become unavailable later.

but it does not mention that even if one calls it early and stores the value for later, it may also become unavailable.

For file activation, the arguments' lifetime is tied to the caller process, so GetActivatedEventArgs may not even work the first time. See #5481

For activation redirection, the activation arguments are only valid during the Activated event. So, again, it is not possible to store the arguments and use them later.

Steps to reproduce the bug

.

Expected behavior

No response

Screenshots

No response

NuGet package version

None

Packaging type

No response

Windows version

No response

IDE

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-ActivationApp activation in Windows App SDK via AppLifecycle for packaged & unpackaged appsarea-LifecycleTopics related to the AppLifecycle, providing lifecycle management for WindowsAppSDK appsneeds-triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions