Winform与UWP应用程序通信

时间:2017-02-17 06:58:36

标签: c# windows winforms uwp

我有一个winform程序,现在我需要增强与UWP应用程序的功能通信,所以我添加了参考Windows.DLL并对winform程序做了一些更改,现在我可以通过方法 Launcher.LaunchUriAsync调用UWP应用程序(),但方法上的任何异常 Launcher.LaunchUriForResultsAsync()

你可以给我一些建议吗?提前谢谢。

异常: 操作标识符无效。 (HRESULT异常:0x800710DD)

部分代码:

   // 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);

1 个答案:

答案 0 :(得分:0)

您可以使用AppServiceConnections。

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

它们用于UWP与其他应用程序的通信,它们在Win32中受支持并且可以相同地工作。