繁体   English   中英

Winform与UWP应用程序通信

[英]Winform communicate with UWP app

我有一个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);

您可以使用AppServiceConnections。

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

它们用于与UWP的其他应用程序进行通信,它们在Win32中得到支持并且工作方式相同。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM