Hi,
Welcome to Microsoft Q&A!
If you use uwp api in wpf app, please add Microsoft.Windows.SDK.Contracts NuGet package instead of Windows.Foundation.FoundationContract and Windows.Foundation.UniversalApiContract .
Besides, you need to add await keyboard for all async methods, such as await args.Request.SendResponseAsync(response). At the same time, please change AppServiceConnectionStatus status = connection.OpenAsync().GetResults() to AppServiceConnectionStatus status = await connection.OpenAsync(). After I modify these as the above, your sample runs well.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.