Communication channel between a windows app and UWP app - c#

I have a uwp project and a windows app (net5).
Both are installed in the same machine (same will happen in production), but the uwp is installed using sideloading, not on windows store.
The windows app gets some data by listening to a wss port. I have to pass those data from the windows app to the uwp app and also wait for a response back from it.
To do this internal communication I came across the AppServiceBridgeSamples in this repo https://github.com/microsoft/DesktopBridgeToUWP-Samples but it is outdated and I can't use it.
Is there any alternatives to it? What would be the easiest implementation to achieve this?
Any suggestions/comments are appreciated.

Currently, the general way to implement a communication channel between a UWP app and a windows app is by using App service. This is not outdated. If you don't want to use the App service, you have to build your own socket server so that both of your apps could communicate with it. Another way is that your windows app could save the data in a local file and load them in the UWP app.

Related

I want to send a string from an android device to a windows machine over wifi with c#. Is this possible?

I want to make a program that transmits strings from an Android device, to the web or directly to my PC.
Do note that the android and windows device are connected to the same wifi if this makes a difference. The problem here is that I do not know how to send strings from one device to another. I am thinking of doing it in a txt file and then reading it with the program on my PC (Which I have already tested), but I don't know how to transmit it.
Yes, you can share a data from cross platform devices. There are many methods to do it. I would personally recommend using Web APIs using asp.net core, the consume that Web API in your android application, it can be in Xamarin, and for Desktop you can used HttpClient package to consume either in WPF or Winform.

Xamarin Forms App as TCP Server

I have a cross-platform Xamarin.Forms app (iOS and Android) which provides a specific service. This service code is in PCL part of the project and I want to use it on web client as well using my app as server. Is there a way to implement TCP server in the app which listens to incoming connections and provides with the service.
Do I have to use platform specific background services to run TCPListener? The server should only be running when the app is in foreground.
I have tried to look for answers over forums and got bits and pieces.
All I need right now is right direction to go to:
Server Client Application with .NET and Xamarin
Xamarin.Forms Background Thread
Sockets PCL Plugin
Any kind of help is highly appreciated.
Cheers.

Establish communication between Universal app and Standalone app developed with Unity3d

I have a UWP app and Unity3d app build for Windows. I have a requirement of establishing communication between UWP app and Unity3d app.Both apps will run on same computer.
Development of Unity3d app and Universal app(Windows 10 native app) both are done in C# language.
Communication should involve:
Launching and closing Unity3d app from UWP app.
Send data from UWP app to Unity3d app.
Receive data from Unity3d app to Windows native app.
I had searched for resources for this but unable to find any. Could someone please share possible ways to achieve the above and resources/examples for those.
Thanks :)
i did this via an Appservice: https://msdn.microsoft.com/en-us/windows/uwp/launch-resume/how-to-create-and-consume-an-app-service in your normal xaml app host the app service and let unity consume data from it.
And via protocol activation the apps can start eachother.

Add/Start/Stop IoT Core application from another application

I would like to add/start/stop/remove an application (IoT Core) just like the web interface or the Power Shell commands: "IotStartup" but from within a C# application running on the IoT Core itself.
Is there a c# API for this or do I have to implement the Power Shell commands inside my application?
Using the Device Portal API could work for you.
Here are the docs.
https://learn.microsoft.com/en-us/windows/uwp/debug-test-perf/device-portal-api-core
Device Portal APIs are intended for remote management, and may not work from within a UWP against localhost due to loopback restrictions in Windows (to prevent an app from attacking the device it's running on).
That said, the Windows.Management.Deployment.PackageManager class provides installation and removal APIs for apps. To launch an app, you can use Windows.System.Launcher. Note that PackageManager is a restricted capability, so the app won't be able to go into the Store without special permissions from Microsoft. It will work in sideloaded scenarios though.
There is no way to close an app from another app with existing APIs. However, Launching the app using the above, then connecting with an AppServiceConnection to manage it, you can send a "Close" message over the AppServiceConnection that causes the app to close itself.

Invoking desktop app from Windows Store app

I have a Windows form desktop application developed using c#. I want to make use of the live tile feature available in WinRT apps (especially for Windows 10). The data in the live tile is to be fetched using WMI queries (Win32_LogicalDisk).
How do I accomplish this? I don't want to rewrite the entire app. Live tiles should update on the background and on clicking the tile, my desktop app exe needs to be invoked. Is it possible to fetch WMI data and invoke exe from Windows Store apps?
I tried using Brokered Windows Runtime components as given in http://blogs.msdn.com/b/dmx/archive/2014/04/30/how-to-trigger-a-desktop-process-from-windows-store-apps-the-easy-way-using-the-brand-new-visual-studio-templates.aspx . But could not get it to work as I get a 'TypeLoadException'.
Thanks in advance.
Metro app can't run a desktop app. However, they can commumicate using wcf. So, you can create tiny windows service that will open wcf host. Then you create windows store app with your live tile(s). When windows service recieves a wcf call, it starts the desktop application.
There is also devexpress' solution that is capable of adding live tiles for desktop apps, however it is not free: https://www.devexpress.com/Products/NET/Controls/WinForms/Live-Tile-Manager/
WinRT blocks network loopback so wcf won't work. You can disable this for testing but I suspect that won't satisfy you. Read more here (and search for WinRT network loopback to find articles on this topic).
https://msdn.microsoft.com/en-us/library/windows/apps/Hh780593.aspx

Categories