Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using AppService with runFullTrust Desktop bridge and allowElevation #93

Open
Ruud-cb opened this issue Oct 25, 2019 · 0 comments
Open

Comments

@Ruud-cb
Copy link

Ruud-cb commented Oct 25, 2019

I have:

  • An UWP App
  • A Console App (.NET Framework)
  • A Package project

This is (part of) the package.appxmanifest that tells you how it is setup:

  <Dependencies>
    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
    <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14393.0" MaxVersionTested="10.0.14393.0" />
  </Dependencies>

  <Resources>
    <Resource Language="x-generate"/>
  </Resources>

  <Applications>
    <Application Id="App"
      Executable="$targetnametoken$.exe"
      EntryPoint="$targetentrypoint$">
      <uap:VisualElements
        DisplayName="CularBytes W10 App"
        Description="Package"
          .... />
      </uap:VisualElements>
      <Extensions>
        <uap:Extension Category="windows.appService">
          <uap:AppService Name="SampleInteropService" />
        </uap:Extension>
        <desktop:Extension Category="windows.fullTrustProcess" Executable="CularBytes.App.WindowsApp.Bridge\CularBytes.App.WindowsApp.Bridge.exe"/>
      </Extensions>
    </Application>
  </Applications>

  <Capabilities>
    <Capability Name="internetClient" />
    <rescap:Capability Name="runFullTrust" />
    <rescap:Capability Name="allowElevation" />
  </Capabilities>

As you can see I want to run it in the same process.

The Console app contains an app.manifest, so that I can define elevated permissions needed:

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

Within the Console app I start the AppService connection:

        private static async void InitializeAppServiceConnection()
        {
            AppServiceConnection Connection = new AppServiceConnection();
            Connection.AppServiceName = "SampleInteropService";
            Connection.PackageFamilyName = Package.Current.Id.FamilyName;
            Connection.RequestReceived += Connection_RequestReceived;
            Connection.ServiceClosed += Connection_ServiceClosed;

            AppServiceConnectionStatus status = await Connection.OpenAsync();
            if (status != AppServiceConnectionStatus.Success)
            {
                // something went wrong ...
                Console.WriteLine("status not success on connecting, status:" + status + " pacakgeName:" + Connection.PackageFamilyName);

            }
            else
            {
                Console.WriteLine("Status success!");
            }
        }

Somewhere from the UWP app, I start the FullTrustProcess like documented:

        if (ApiInformation.IsApiContractPresent("Windows.ApplicationModel.FullTrustAppContract", 1, 0))
        {
            await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();
        }

The console app starts like expected but the connection is not successful, console.writeline prints:

status not success on connecting, status:Unknown pacakgeName:df84c6a8....

I verified that the packageName is correct.

When I remove <rescap:Capability Name="allowElevation" /> from Package.appxmanifest and <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> from app.manifest, then the connection is successful!

So why, due elevated client-app, is the connection not working?

I need elevated permissions to do more actions from the console app. Don't bother asking what that is, I know I will have Microsoft Store limitations, etc. Please help me solve this issue.

Do I need to use another packageName? Is that changed when using allowElevation? How can I find this out?

@Ruud-cb Ruud-cb changed the title runFullTrust Desktop bridge with allowElevation Using AppService with runFullTrust Desktop bridge and allowElevation Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant