We are fixing to re-architect an application and are debating whether or not it is possible to use UWP instead of an ordinary WPF application.
Our application needs the ability the access the entire filesystem and all system resources. This is an issue since UWP apps are sandboxed. However, we are trying to bypass that issue by trying to approach it in this manner:
Windows Service -> Running on the system at all times. This will host the core functionality when it comes to accessing and modifying system resources.
UWP Application -> Since UWP is sandboxed, the UWP app will forward all system requests to the Windows Service, which will do all of the brunt work and just return the output.
We can simply do this in WPF, but we would like to use UWP in order to utilize some new Windows 10 core features WPF is lacking such as live tiles and Cortana.
Do you think our approach is feasible? One of our uncertainties is how we can get the UWP app to communicate with the Windows Service- we've looked into things like SignalR and the Desktop Bridge but are unsure which may be the best approach for our scenario.
Thanks!
Microsoft continues to baby-step around the obvious, but it has officially deprecated the Universal Windows Platform (UWP) as it pushes the desktop-focused Windows App SDK (formerly called Project Reunion) and WinUI 3 as the future of Windows application development.
If you are distributing your app via the Microsoft Store, Visual Studio can associate your package with the Store. To do this, right-click your project name in Solution Explorer and choose Publish->Associate App with the Store (before Visual Studio 2019 version 16.3, the Publish menu is named Store).
UWP is one choice for creating apps that run on Windows 10 and Windows 11 devices, and can be combined with other platforms. UWP apps can make use of Win32 APIs and .
However, in a Universal Windows Platform application, access to the Registry is forbidden.
You could use a windows service (which has access to most of the system) to do the communication for you. The windows service itself communicates with the UWP application via a WCF service (a "server", reachable for example via localhost:900/MyService.wcf/MyCall).
Win32Communication is an example of how to communicate between a UWP app and an external Win32 Desktop app. Note: This sample is a Desktop Bridge app that uses a Desktop Extension to launch the external Win32 Desktop app.
A Universal Windows Platform (UWP) app (or a Windows Runtime component) written in C++ has access to the Win32 and COM APIs that are part of the Universal Windows Platform (UWP). Windows Runtime components are self-contained objects that you can instantiate and use from any language, including C#, Visual Basic, JavaScript, and C++.
Windows Service -> Running on the system at all times. This will host the core functionality when it comes to accessing and modifying system resources. UWP Application -> Since UWP is sandboxed, the UWP app will forward all system requests to the Windows Service, which will do all of the brunt work and just return the output.
Do you think our approach is feasible?
We cannot directly consume a Windows Service in an UWP app. In order to make the IPC between Win32 app and UWP app, what may help here is using the new Capability <rescap:Capability Name="runFullTrust" />
, and it enable the Win32 app which is launched by the FullTrustProcessLauncher
API to achieve the uplevel app security context to consume WinRT APIs. But as you see the rescap
here, it means this UWP app cannot be published in Store.
You can refer to the official AppService Bridge Sample. You can try to firstly create a traditional desktop app which consume App service (which can communicate with WPF and UWP app, not traditional Windows service) and use WinRT APIs, after building this app (don't run it), a .exe file will be generated. But this app cannot run since it uses WinRT API, then you can create your UWP app to make this desktop app executable.
we've looked into things like SignalR and the Desktop Bridge but are unsure which may be the best approach for our scenario.
So I think the Desktop Bridge may be the best approach here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With