I have a UWP app that has 2 main parts, a UWP project that has the UI and a WinForms project that is used to provide system tray functionality. I am using a Windows Application Packaging project to join these together as in this example: https://learn.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-extend#show-a-modern-xaml-ui .
When the app launches the WinForm app is launched first and resides in the system tray. When one of it's menu options is selected the UWP app is launched and navigates to the appropriate page using the protocol approach from the example (ie Windows.System.Launcher.LaunchUriAsync("myapp://action?key=value");
). This is working fine.
The problem I have is that I would like to be able to communicate from the UWP app to the WinForms app (maybe the other way too in some cases). I am trying to achieve this using the App Service extension. I have been following the example here: https://stefanwick.com/2017/06/24/uwp-app-with-systray-extension/ . However I cannot get this to work. I'm not quite sure which project the fulltrust and app service declarations should be in.
If I put them in my UWP project as in the example I always get an AppServiceUnavailable error (the name is definitely correct - I have no idea what the version that the documentation for this status refers to but I can't see how it can be incorrect). This happens regardless of whether the UWP app is open at the time or not. Previously I have got this approach working but only when there was no Windows Application Packaging project involved and the UWP app launched first which I don't want.
If I put the declarations in the Windows Application Packaging project (setting the app service executable and entry point to the UWP project App class), I get an AppUnavailable error which I guess means it's failing at an earlier point.
Does anyone know how I can get this working? If it's not possible for some reason can anyone point me in the right direction for achieving this idea (a UWP app that does not launch any windows on startup and resides in the system tray with bi-directional messaging between any components required).
EDIT: Target version: 17763, Min version: 16299, Windows version: 17763
EDIT2: I've created a small test solution that hopefully shows what I'm trying to do better: https://github.com/csuzw/AppServiceTest .