JasonWei512 / EnergyStarX

🔋 Improve your Windows 11 device's battery life. A WinUI 3 GUI for https://github.com/imbushuo/EnergyStar.
https://www.microsoft.com/store/productId/9NF7JTB3B17P
GNU General Public License v3.0
906 stars 19 forks source link

Feature: Mimic UWP's single instance app mode / 功能:模仿 UWP 的单实例应用模式 #10

Closed JasonWei512 closed 1 year ago

JasonWei512 commented 1 year ago

Current behavior:

When launching a second app instance, show a toast notification that tells user the app is already running, and exit.

New behavior:

When launching a second app instance, redirect activation to the main app instance, and show main instance's app window, just like UWP's default behavior.

Problems:

There's something wrong with GitHub Action's CI builds. When I launch a second instance, RedirectActivationToAsync in Program.cs will crash the app, so main instance's window will not show. The exception message is:

The process was terminated due to an unhandled exception.
Exception Info: System.Runtime.InteropServices.COMException (0x80040155): Interface not registered (0x80040155)

If I compile the app on my PC it works fine.


当前行为:

启动第二个应用实例时,弹出一条通知告诉用户应用已经在运行,然后退出。

新的行为:

启动第二个应用实例时,把激活重定向到主实例,并显示主实例的窗口,就像 UWP 的默认行为一样。

问题:

GitHub Action 的 CI 构建的包有点问题。启动第二个实例时,Program.cs 中的 RedirectActivationToAsync 会使应用崩溃,所以主实例的窗口不会显示。异常信息为:

The process was terminated due to an unhandled exception.
Exception Info: System.Runtime.InteropServices.COMException (0x80040155): Interface not registered (0x80040155)

在我的电脑上编译就没有这个问题。

nodew commented 1 year ago

I got the same problem when I compile with RedirectActivationToAsync. Do you find out the root cause?

The process was terminated due to an unhandled exception.
Exception Info: System.Runtime.InteropServices.COMException (0x80040155): Interface not registered (0x80040155)
JasonWei512 commented 1 year ago

I got the same problem when I compile with RedirectActivationToAsync. Do you find out the root cause?

The process was terminated due to an unhandled exception.
Exception Info: System.Runtime.InteropServices.COMException (0x80040155): Interface not registered (0x80040155)

No yet.

nodew commented 1 year ago

Created an issue at the WindowsAppSDK repo RedirectActivationToAsync throws System.Runtime.InteropServices.COMException: 'Interface not registered (0x80040155)'