WindowsAppSDK icon indicating copy to clipboard operation
WindowsAppSDK copied to clipboard

When opening the file from the console an exception is triggered -> RPC server is unavailable.

Open lgBlog opened this issue 7 months ago • 0 comments

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

  1. Create an empty WINUI3 project.

  2. Add in the MainWindow function var args = AppInstance.GetCurrent().GetActivatedEventArgs();

  3. Create a file type association .txt

  4. Set the opening method of the txt type to the current application.

  5. 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!");
}
  1. Start WINUI3 debugging.
  2. 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

ConsoleApp1.zip

App3.zip

Image

NuGet package version

None

Packaging type

Packaged (MSIX)

Windows version

No response

IDE

Visual Studio 2022

Additional context

No response

lgBlog avatar May 30 '25 07:05 lgBlog