Search code examples
wcfuwpsystem-traydesktop-bridge

Issues in launching desktop extension code from UWP app


I have a requirement to host a WCF service to receive responses from a service. As UWP app doesn’t have wcf hosting capabilities, I chose this system tray component where I will host my service so that I get responses and communicate to UWP app via app service and show toasts.

But the systray component terminates immediately after the launch. To be clear on my systray integration with uwp I already tested it and is working and then extended it with WCF hosting.

Later I tried adding debugs showing message box on exceptions and found out that WCF service open call throwing below exception.

"System.ServiceModel.AddressAccessDeniedException: HTTP could not register URL http::1234"

Later understood that the sys tray app requires admin rights to register the URL that is hosted as part of the service and as UWP app launches sys tray via full trust API and it doesn't do through admin elevation.

So to solve this I got 2 approaches and tried as mentioned below:

1) So I tried adding URL reg manually using netsh and same program works. Just to tweak I tried running the "same netsh command in sys tray app itself with admin priv" and only launched the tray app and i could see no exception and could see my service hosted, checked in browser.

Now I'm stuck with providing admin privileges while launching the sys tray app via UWP app.

But if tray app is launched by UWP, even though I included the netsh command it still shows the same exception. (Might be parent process (as run as admin is N/A UWP apps) is not having admin rights so even my netsh cmd in sys tray app is not working??? )

OR is there any way to provide arguments or any other API to run the tray app with admin via full trust api's from UWP app???

2) Tried adding app manifest file to the tray app and modified as below

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

But this also shows a error box saying this requires elevation and exited.

Kindly Help.


Solution

  • Requesting elevated privileges is currently not supported for desktop-bridge processes. So what you are seeing here is currently expected. The good news is that we are adding a new capability in RS5 (Fall 2018 update) called 'allowElevation', which will enable scenarios that require elevation.

    You should be able to start testing the new capability with the latest Windows Insider Preview build and the corresponding SDK.

    UPDATE 10/1/2018: I have posted a sample for this new capability https://stefanwick.com/2018/10/01/app-elevation-samples-part-1/