microsoft / microsoft/WindowsAppSDK

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

Open
#5,481 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

area-Activation needs-triage
Dominant language
C++
Stars
4.7k
Forks
471
Avg merge
3d 13h
Merged PRs (30d)
28

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

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!");
}
```

6. Start WINUI3 debugging.
7. 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](https://github.com/user-attachments/files/20516967/ConsoleApp1.zip)

[App3.zip](https://github.com/user-attachments/files/20516962/App3.zip)

![Image](https://github.com/user-attachments/assets/4bbf1723-bd23-4055-b694-cd5bce3f5bad)

### NuGet package version

None

### Packaging type

Packaged (MSIX)

### Windows version

_No response_

### IDE

Visual Studio 2022

### Additional context

_No response_

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied ConsoleApp1.zip and App3.zip reproducers, then trace the MainWindow call to AppInstance.GetCurrent().GetActivatedEventArgs() while opening D:\test.txt through the system default application. Done means the packaged WinUI3 app raises no RPC-server exception and receives the activation parameters correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.