简体   繁体   English

Winform与UWP应用程序通信

[英]Winform communicate with UWP app

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

Could you provide me some advice? 你能给我一些建议吗? Thanks in advance. 提前致谢。

Exception: The operation identifier is not valid. 例外:操作标识符无效。 (Exception from HRESULT: 0x800710DD) (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);

You can use AppServiceConnections. 您可以使用AppServiceConnections。

https://docs.microsoft.com/en-us/windows/uwp/launch-resume/how-to-create-and-consume-an-app-service 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. 它们用于与UWP的其他应用程序进行通信,它们在Win32中得到支持并且工作方式相同。

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

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