1

I am trying to launch MAUI app-A from MAUI app-B in Windows. After launching app-A, I want that app-A will send in response some API-Object to control app-A from app-B.

I need to control more than one instance of App-A from App-B, so that each instance of app-A need to return its own API-Object.

  1. I tried to use Microsoft.Maui.ApplicationModelLuncher https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/appmodel/launcher?tabs=windows but it doesn't return value as response (it returns true/false for success/failure)

  2. I tried to use Windows.System.Launcher.LaunchUriForResultsAsync

 var testAppUri = new Uri($"App_A:"); // The protocol handled by the launched app
 var options = new LauncherOptions();
 options.TargetApplicationPackageFamilyName = Windows.ApplicationModel.Package.Current.Id.FamilyName;

 var inputData = new ValueSet();
 inputData["sn"] = sn;
 LaunchUriResult result = 
          await Windows.System.Launcher.LaunchUriForResultsAsync(testAppUri, options, inputData);

but I am getting exception

System.InvalidOperationException: 'Element not found.

LarsTech
  • 80,625
  • 14
  • 153
  • 225
YChabany
  • 11
  • 1
  • If you are comfortable with a Windows-only solution, then you can use a variety of IPCs to communicate between the processes: named pipes, sockets, zeroMQ or other broker, COM, even stdin/stdout redirection. There is no need to use the MAUI-specific API if you do not need a cross-platform solution (although it is a good idea to use the cross-platform API if it exists and meets the task requirements). – Serg May 17 '23 at 00:13
  • 1
    thanks, I used named pipes eventually. :) – YChabany May 29 '23 at 15:51
  • Did you solve this @YChabany ? How do you launch app-A from app-B? – Smith5727 Aug 15 '23 at 11:51

0 Answers0