UWP App Communication with Windows Service

女生的网名这么多〃 提交于 2019-12-03 19:34:48

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/40536376/uwp-app-communication-with-windows-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!