Edge浏览器的每个请求都需要发送相应的响应.如果没有,配套UWP(和相关的Win32 App,如果有的话)退出引用“SystemPolicy”作为原因.
为了说明这个问题,我可以参考
SecureInput样本.
/// <summary>
/// Receives message from Extension (via Edge)
/// </summary>
private async void OnAppServiceRequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args)
{
AppServiceDeferral messageDeferral = args.GetDeferral();
try
{
if (this.desktopBridgeAppLaunched)
{
this.currentConnectionIndex = Int32.Parse(sender.AppServiceName);
this.desktopBridgeConnection = desktopBridgeConnections[this.currentConnectionIndex];
// Send message to the desktopBridge component and wait for response
AppServiceResponse desktopBridgeResponse = await this.desktopBridgeConnection.SendMessageAsync(args.Request.Message);
await args.Request.SendResponseAsync(desktopBridgeResponse.Message);
}
else
{
throw new Exception("Failed to launch desktopBridge App!");
}
}
finally
{
messageDeferral.Complete();
}
}
通过注释掉调用“SendResponseAsync(…)”的行,UWP和Win32应用程序(PasswordInputProtection.exe)正在退出,因为使用SystemPolicy原因调用了“OnAppServicesCanceled(…)”处理程序.
我理解,对于这个特定的例子,不发送回复是没有意义的.但我有一些场景,不需要将响应发送回Edge Extension.相反,我打算使用Win32 App中的SendMessageAsync(…)通过UWP App与Extension进行通信.
此外,我注意到我在网上找到的本机消息样本至少发送了一条无用的ACK消息,从UWP发送回扩展.那么,设计是否需要发送响应或者我在这里遗漏了什么?
最佳答案 Edge团队对此进行了调查,并确认这是其中一个组件中的错误.他们正在努力修复下一次更新.在修复完成之前,您需要始终发送响应.
感谢您报告此问题,并对由此造成的不便表示歉意!