Repository: microsoft/WindowsAppSDK

Issue #3941: Implementing ShareTarget API opens 'Ghost'/Empty Unknown Window
Created: 2023-11-06T23:51:29Z
Describe the bug
Looking at the Share Target API, it's hard to translate the UWP docs to the Windows App SDK, which leads to unexpected issues implementing the contract.
The rich activation docs seem to indicate that any of these activation types should be supported, but don't cover this specific scenario. Similar to the app instancing docs. They also have no C# examples for these concepts.
Using my WinUI2/3 template, I setup this scenario and have it working fine in UWP, but with what I have with the similar APIs in the Windows App SDK, results in an extra blank window:

Compared to UWP:

It's unclear if additional steps are required upon app activation in the Windows App SDK to use the same window instance being created by the Share API? Or if that's what's happening...
In UWP, the activation path is separate, but the developer follows the same idea of setting the Window's content. In the Windows App SDK space, the Window is normally created by the OnLaunched method...
Steps to reproduce the bug
WindowsShareExample.zip

Unzip the attached project
Build, deploy, and launch (without debugging) the UWP version of the app.
Build, deploy, and launch the WinAppSDK version of the app.
In the WinAppSDK app, type in the textbox and click on Share:

Click on the UWP version of the app as the share target:

You should see a new instance of the UWP app open with the received data (you can close this new window):

Repeat steps 4-6 but starting from the UWP app and selecting the WinAppSDK app as the target:



See that the share data can be retrieved, but there is a 'ghost' window that was opened instead of our app taking ownership of that:

I only see one activation event of the app for the Windows App SDK without an existing Window and with the share data, so it's unclear what's required here of a developer or if this is something unique to the hand-off required with a Windows App SDK app.
Expected behavior
Able to implement ShareTarget API without extra empty Window, either replacing it or filling it with content, or something...
Screenshots
No response
NuGet package version
Windows App SDK 1.4.2: 1.4.231008000
Packaging type
Packaged (MSIX)
Windows version
Windows 11 version 22H2 (22621, 2022 Update)
IDE
Visual Studio 2022
Additional context
Possibly Related Issues:

#3777
#2174

Duplicate issue #3943: Application as a ShareTarget works but it's opening an additional window with the splash image
Created: 2023-11-08T03:07:11Z
Describe the bug
Original report in MAUI issue #18536
Same problem with a new fresh WinUI3 application.
Steps to reproduce the bug
I described all steps for a .NET MAUI application here
For WinUI3 it's kind of the same:

Create a new WinUI3 application (I used the Template Studio for WinUI but it's the same if you create the app with the "Blank App, Packaged (WinUI 3 in Desktop)" option).



Set up the application as a Share Target by updating the Package.appxmanifest.

Run the application.

Go to a file and share it using the WinUI3 application.



Two windows will be opened:

The WinUI3 application.
A blank window with the splash logo.


WinUI3 is also showing the splash logo in the blank window. The difference between .NET MAUI and WinUI3 is that WinUI3 has the splash logo at Assets/SplashScreen.scale-200.png. You can confirm that with the next steps:

Uninstall the WinUI3 app from Windows (and stop the app if you're running it with visual studio).

Replace the Assets/SplashScreen.scale-200.png file with a custom png file.

Clean the solution.
Build the solution.
Run the application.

Share a file using the WinUI3 app.



Two windows will be opened:

Expected behavior
Only the application window should be opened after selecting the application to share a file.
Screenshots
No response
NuGet package version
None
Packaging type
Packaged (MSIX)
Windows version
No response
IDE
Visual Studio 2022
Additional context
I am using Windows 11 version 23H2 (OS Build 22631.2506)
More info:

Closing comment (2024-03-01T21:17:24Z): Dupe of #3941. See the comment that I added there for me info.