Winform communicate with UWP app

1

I have a winform program, now I need to enhance feature communicate with UWP app, so I added reference Windows.DLL and did some change for winform program, now I can call UWP app thru the method Launcher.LaunchUriAsync(), but any an exception on method Launcher.LaunchUriForResultsAsync(),

Could you provide me some advice? Thanks in advance.

Exception: The operation identifier is not valid. (Exception from HRESULT: 0x800710DD)

Some Code:

   // The protocol handled by the launched app
    Uri testAppUri = new Uri("etrace.scanner:"); 
    var supportStatus = await Launcher.QueryUriSupportAsync(testAppUri, LaunchQuerySupportType.Uri, "80a2fbc7-843e-46ca-a740-cbb1bc604d33_y890260wv9vv0");
    if (supportStatus != LaunchQuerySupportStatus.Available)
    {
        // Check the app available or not.
    }

    var inputData = new ValueSet();
    inputData["TestData"] = "Test data";
    var optionsE = new LauncherOptions { TargetApplicationPackageFamilyName = "80a2fbc7-843e-46ca-a740-cbb1bc604d33_y890260wv9vv0"  };
    // Call APP successully.
    bool success = await Launcher.LaunchUriAsync(testAppUri, optionsE, inputData);
    Debug.WriteLine(success);

    // Got an exception: 
    var result = await Launcher.LaunchUriForResultsAsync(testAppUri, optionsE, inputData);
c#
windows
winforms
uwp
asked on Stack Overflow Feb 17, 2017 by JKhuang

1 Answer

0

You can use AppServiceConnections.

https://docs.microsoft.com/en-us/windows/uwp/launch-resume/how-to-create-and-consume-an-app-service

They're for communication with other apps for UWP and they're supported in Win32 and work the same.

answered on Stack Overflow Nov 19, 2018 by Adam Dernis

User contributions licensed under CC BY-SA 3.0