Skip to content

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

Open
@lgBlog

Description

@lgBlog

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions