Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protocol Activation - Unpackaged App: Microsoft.Windows.AppLifecycle.AppInstance.GetActivatedEventArgs() returns object with Data as WinRT.IInspectable #9225

Closed
AdriaanLarcai opened this issue Jan 11, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@AdriaanLarcai
Copy link

AdriaanLarcai commented Jan 11, 2024

Describe the bug

Attempting to get single instancing working via protocol activation in a Self Contained Unpackaged app.
When attempting to retrieve AppActivationArguments during app startup using GetActivatedEventArgs() method on the current AppInstance returns an AppActivationArguments object where the Data property is returned as a WinRT.IInspectable object. The returned WinRT.IInspectable is unusable and attempting to resolve it always results in protected memory access exceptions.

Steps to reproduce the bug

Create a new WinUI3 Unpackaged project.
Implement the single instancing pattern by overriding the generated program.cs and attempt to retrieve the AppActivationArguments by calling Microsoft.Windows.AppLifecycle.AppInstance.GetCurrent().GetActivatedEventArgs() when the app is started.
Inspect the Data property of the AppActivationArguments object.

Expected behavior

The AppActivationArguments Data property should be set to the appropriate IActivatedEventArgs implementation based on the launch type (Launch, Protocol, etc.) as it is when building and running a Packaged app.

Screenshots

image

NuGet package version

WinUI 3 - Windows App SDK 1.4.3: 1.4.231115000

Windows version

Windows 11 (22H2): Build 22621

Additional context

No response

@AdriaanLarcai AdriaanLarcai added the bug Something isn't working label Jan 11, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Jan 11, 2024
@AdriaanLarcai AdriaanLarcai changed the title Unpackaged App: Microsoft.Windows.AppLifecycle.AppInstance.GetActivatedEventArgs() returns object with Data as WinRT.IInspectable Protocol Activation - Unpackaged App: Microsoft.Windows.AppLifecycle.AppInstance.GetActivatedEventArgs() returns object with Data as WinRT.IInspectable Jan 15, 2024
@DarranRowe
Copy link

Forgive me if I missed something, but besides this being an issue that is better placed in the Windows App SDK repository, isn't this behaviour expected?
In an unpackaged situation, the argument can refer to four distinct startup types. Each of these use a different interface type. What's more, when packaged, this is extended to the 44 supported by Windows, but it then uses the inbuilt Windows activation functionality. This is also part of the API, the AppActivationArguments.Data property is documented to return IInspectable/Object. .NET projects IInspectable to Object. The idea here is that you obtain the instance of AppActivationArguments, inspect AppActivationArguments.Kind to tell what kind of activation that you are working with, retrieve the IInspectable instance from AppActivationArguments.Data and then query this for the appropriate interface based upon Kind. There is information on this in the documentation. You can also show samples illustrating this too.
While there is some slight differences, this is also the way that UWP does it. Windows.ApplicationModel.AppInstance.GetActivatedEventArgs returns an IActivatedEventArgs here. You would then query IActivatedEventArgs.Kind then query this for the appropriate interface based upon Kind.

@AdriaanLarcai AdriaanLarcai closed this as not planned Won't fix, can't repro, duplicate, stale Jan 18, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot removed the needs-triage Issue needs to be triaged by the area owners label Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants