question

muthupandi-9833 avatar image
1 Vote"
muthupandi-9833 asked AryaDing-MSFT commented

UWP- Desktop extension using App service connection was failed or throw null exception

Hi guys,

I have created a packaging application that contains a UWP app(Main app) and a WPF app. In that, I had explored the app service connection between UWP and WPF for passing arguments from those ones.

So I had followed the steps which are mentioned on the below page.

uwp-with-desktop-extension-part-3


I had established a connection, but it returns the status as a failure or sometimes the connection was closed(Null Exception). I didn't know what mistakes I had done. Anyone can help me with this?

TIA

Github URL : WorksManager


windows-uwpdotnet-package-management
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@muthupandi-9833 We noticed that you seemed to comment and then deleted something, do you have any other concerns?

0 Votes 0 ·

1 Answer

AryaDing-MSFT avatar image
1 Vote"
AryaDing-MSFT answered AryaDing-MSFT commented

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.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @AryaDing-MSFT ,

I had tried your answer as remove the Windows.Foundation.FoundationContract and Windows.Foundation.UniversalApiContract.

Added mentioned NuGet packages. But some of the references are shows, to add the removed package.

103688-image.png



May I know How to rectify that?

0 Votes 0 ·
image.png (26.8 KiB)

@muthupandi-9833
After we remove the reference of Windows.Foundation.FoundationContract and Windows.Foundation.UniversalApiContract, your sample still works well on my PC.
Your error message seems to be that the AppServiceConnection class doesn’t identify SDK.Contracts package. Maybe you could check whether you install the correct version of Microsoft.Windows.SDK.Contracts NuGet package, this link mentions you need to install the corresponding version of SDK.Contracts according to the operation system version. Besides, please make sure the target version of your Packaging project(WorksManagerPackage) matches SDK.Contracts version.
Finally, I suggest you could clean and rebuild the solution. If you still have questions, please share the reference screenshot of wpf app with us.


0 Votes 0 ·