Open
Description
Describe the bug
Call the system's default application from the console to open the txt file.
An exception is triggered when AppInstance.GetCurrent().GetActivatedEventArgs() is called.
Steps to reproduce the bug
-
Create an empty WINUI3 project.
-
Add in the MainWindow function
var args = AppInstance.GetCurrent().GetActivatedEventArgs();
-
Create a file type association .txt
-
Set the opening method of the txt type to the current application.
-
Create a new net8 console application and add the following code, and create a test.txt document on the D drive.
static void Main(string[] args)
{
var startInfo = new ProcessStartInfo
{
FileName = "D:\\test.txt",
UseShellExecute = true // Open with the system default program
};
Process.Start(startInfo);
Console.WriteLine("Hello, World!");
}
- Start WINUI3 debugging.
- Run the console application.
Expected behavior
No exception occurs, and the activation parameters can be obtained correctly
Screenshots
Reference example, a console and a winui3
NuGet package version
None
Packaging type
Packaged (MSIX)
Windows version
No response
IDE
Visual Studio 2022
Additional context
No response