我有一個旨在用作SignalR客戶端的UWP Windows 10應用程序。我有這個工作之前,但最近開始得到這個錯誤:Error HRESULT E_FAIL has been returned from a call to a COM component
。不知道是什麼改變了,沒有什麼奇怪的源代碼管理。當我嘗試通過ApplicationTrigger
觸發後臺任務時出現。UWP(Windows 10)後臺任務 - 錯誤HRESULT E_FAIL已從調用COM組件(VS2017)返回
這裏是我的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消息。