Hello,
Welcome to our Microsoft Q&A platform!
I do not understand, why the logic of the actual application service has to be implemented in a separate project, whose type is 'Windows Runtime Component'.
This is actually an out-of-process application service. An app service can be implemented as a background task. This enables a foreground application to invoke an app service in another application. To create an app service as a background task, add a new Windows Runtime component project to the solution, so the background task that runs in a separate process than your app's process.
So I thought, why not to merge the two projects - AppServiceProvider and MyAppService into one project only.
This is feasible. In that case, it changes from out-of-process application services to in-process application services, two running foreground applications can have a direct line of communication via an app service connection. App Services can now run in the same process as the foreground application and removes the need to separate the service code into a separate project.
But first you need to modify the manifest, removing the EntryPoint attribute from the element because now OnBackgroundActivated() is the entry point that will be used when the app service is invoked.
.manifest:
<Extensions>
<uap:Extension Category="windows.appService">
<uap:AppService Name="InProcessAppService" />
</uap:Extension>
</Extensions>
Then moving the service logic from its separate background task project into methods that can be called from OnBackgroundActivated() in App.xaml.cs.
Finally, in your client app, changing your AppServiceName to InProcessAppService. For more detail about this, you can refer to this document.