0

I'm currently developing a UWP application that now needs access to APIs that are normally not accessible by apps in an AppContainer.
As I'm not (yet) able to migrate to WinUI3, I want to try using DesktopBridge to do the otherwise restricted work.

As both processes have to communicate with each other, I thought of COM as it should make things relatively seamless once everything has been set up.
According to this page this should be possible using "Packaged Com".
I now have...

  • An Out-of-Process Com Server (c# net5.0) that is accessible by non-packaged win32 apps (e.g., PowerShell) but not my own UWP App.
  • The UWP App with the main logic and UI.
  • A Packaging Project, which creates a package out of both projects. (Manifest)

The code is on GitHub: Repo.

Does someone have an idea how to solve this problem or got an alternative for IPC?

PS: Tutorials I used
Packaged Com
Out-Of-Proc COM in c#
Packaging / DesktopBridge

1 Answers1

0

So if I understand you correctly, you want to communicate between a UWP app and a Win32 app, and these two apps are packaged inside a Windows Application Package Project. Please let me know if it is not correct.

For your scenario, since the two apps are packaged together with desktop bridge, I'd suggest you use the App Service. App service could be used not only between UWP apps but also between the UWP app and desktop app.

These are the detailed steps:

  1. You need to declare the AppService connection in the Manifest file of the package project.
  2. You need to call the App service API in the win32 application.
  3. You need to handle the connection in the App.xaml.cs in the UWP app

You could check the detailed code and sample from Stefan Wick's blog - UWP with Desktop Extension – Part 3.

Roy Li - MSFT
  • 8,043
  • 1
  • 7
  • 13
  • Yes, that’s pretty much what I want to do. I’ve seen AppService, although I didn’t try to implement it yet, because it seems that I would have to create some kind of custom (websocket-like) protocol. Do you know of an alternative (e.g. some way of using COM Interop)? If not: Is it possible to use AppServices for this Scenario with a multiple instance app? – ShortDevelopment Jan 10 '22 at 15:46
  • I have to say there are no alternatives for this unless you build a real socket connection between your UWP app and the win32 app. The app service tutorial I shared is limited to standard, single-instance UWP applications. – Roy Li - MSFT Jan 11 '22 at 08:27
  • IPC mechanisms available to an app running in LowIL (UWP) are listed here: https://learn.microsoft.com/en-us/windows/uwp/communication/interprocess-communication If you need a high bandwidth communication, you will want to look into NamedPipes or SharedMemory - it can be a little tricky to setup the ACLs - https://learn.microsoft.com/en-us/windows/uwp/communication/sharing-named-objects – Adam Braden - MSFT Mar 08 '22 at 19:30