App Services


AppServiceConnection connectio = new AppServiceConnection();
connection.AppServiceName = "microsoftDX-appservicesdemo";   // Manifest of the App which host the App Service, must only be unique in the app
connection.PackageFamilyName = "24919ArunjeetSingh.InstapaperIt";   // From Store, after registered the App
AppServiceConnectionStatus connectionStatus = await connection.OpenAsync();:

if(connectionStatus == AppServiceConnectionStatus.Success)
  var message = new ValueSet();
  message.Add("Command", "CalcSum");
  message.Add("Value1", Int.Parse(Value1.Text));
  message.Add("Value2", Int.Parse(Value2.Text));
  AppServiceResponse response = await connection.SendMessageAsync(message);

  if(response.Status == AppServiceResponseStatus.Success)
    int sum = (int)response.Message["Result"];
    new MessageDialog("Result=" + sum).ShowAsync();
  // Drive the user to the store to install the app that provides the app service



namespace AppServicesDemoTask
  public sealed class AppServiceTask : IBackgroundTask
    private static BackgroundTaskDeferral _serviceDeferral;
    public void Run(IBackgroundTaskInstance taskInstance)
  taskInstance.Canceled += TaskInstance_Canceled;
  _serviceDeferral = taskInstance.GetDeferral();
  var appService = taskInstance.TriggerDetails as AppServiceTriggerDetails;
  if(appService.Name == "microsoftDX-appservicesdemo")
    appService.AppServiceConnection.RequestReceived += RequestReceived;

Request Received

private async void RequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args)
  var message = args.Request.Message;
  string command = message["Command"] as string;
  switch (command)
    case "DoIt":
      var messageDeferral = args.GetDeferral();
      int value1 = (int)message["Value1"];
      // ... calc
      var returnMessage = new ValueSet();
      returnMessage.Add("Result", result);
      var responseStatus= await args.Request.SendResponseAsync(returnMessage);

    case "Quit":

Declaring App Service


<?xml ...
<Package ...
  <Application Id="App" ...>
    <uap:Extension Category="windows.appService" EntryPoint="AppServicesDemoTask.AppServiceTask">
    <uap:AppService Name="microsftDX-appServicesdemo" />   // must be unique in the app.

Two-way Communication


AppServiceConnectionStatus connectionStatus = await connection.OpenAsync();

if(connectionSttaus == AppServiceConnectionStatus.Success)
  connection.RequestReceived += OnRequestReceived;

 Debugging Tips

var currentPackage = Windows.ApplicationModel.Package.Current;
var packageFamilyName = currentPackage.Id.FamilyName;


  1. Set breakpoints in app service
  2. Check „Do not launch, but debug my code when it starts“ in project properties
  3. Launch app service foreground app in debugger
  4. Run client app  to connect to app servcie
  5. Debugger attaches and breaks on your breakpoint