【发布时间】:2018-03-17 09:28:31
【问题描述】:
我有一个旨在用作 SignalR 客户端的 UWP Windows 10 应用。我以前有这个工作,但最近开始出现这个错误:Error HRESULT E_FAIL has been returned from a call to a COM component。不知道发生了什么变化,源代码控制中没有什么奇怪的。当我尝试通过ApplicationTrigger 触发后台任务时,它会出现。
这是我的 App.XML 中的代码:
private void SignalR()
{
_hubConnection = new HubConnection("http://localhost/hollerhub");
_hubConnection.Credentials = CredentialCache.DefaultCredentials;
_toast = _hubConnection.CreateHubProxy("toast");
_toast.On<string>("broadcastMessage", msg =>
{
var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
localSettings.Values["toastInfo"] = msg;
var appTrigger = new ApplicationTrigger();
appTrigger.RequestAsync().GetResults(); // <--- This is where the error is thrown
});
_hubConnection.Start();
}
后台任务在应用启动时注册,但在失败之前ApplicationTrigger 没有到达我的后台任务代码。它正在接收 SignalR 消息就好了。
【问题讨论】:
标签: c# uwp signalr visual-studio-2017 template10