Skip to content

Getting LaunchActivatedEventArgs crashes in release mode #1342

Open
@lhak

Description

@lhak

Describe the bug

See the attached repro project. When getting the activation arguments in Main (App.xaml.cs), the application will crash with a System.NullReferenceException. Please note that this only happens in Release (x64) mode with PublishReadyToRun enabled (the default value).
ActivationArgsRepro.zip

The following change seems to somehow workaround this issue

AppActivationArguments activatedArgs = AppInstance.GetCurrent().GetActivatedEventArgs();
Windows.ApplicationModel.Activation.LaunchActivatedEventArgs launchArgs = activatedArgs.Data as Windows.ApplicationModel.Activation.LaunchActivatedEventArgs;
launchArgs.Kind.ToString(); // Add this line to avoid a crash
if (launchArgs.Arguments.StartsWith("argument"))
{

}

Steps to reproduce the bug

  1. Run the attached repro project in Release mode (x64)

Expected behavior

No response

Screenshots

No response

NuGet package version

1.1.4

Packaging type

Packaged (MSIX)

Windows version

Windows 11 version 21H2 (22000)

IDE

Visual Studio 2022

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions