如何解决System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess任务任务:HRESULT:0x80640012
private static async void OnConnectionRequestedAsync(WiFiDirectConnectionListener sender,WiFiDirectConnectionRequestedEventArgs eventArgs)
{
WiFiDirectConnectionRequest connectionRequest = eventArgs.GetConnectionRequest();
string deviceName = connectionRequest.DeviceInformation.Name;
string deviceID = connectionRequest.DeviceInformation.Id;
DeviceInformation devinfo = connectionRequest.DeviceInformation;
bool isPaired = (devinfo.Pairing?.IsPaired == true) ||
(await IsAepPairedAsync(deviceID));
try
{
// IMPORTANT: FromIdAsync needs to be called from the UI thread
if (Application.Current.Dispatcher.CheckAccess())
{
_wfdDevice = await WiFiDirectDevice.FromIdAsync(deviceID);
}
else
{
await Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal,new Action(async () =>
{
_wfdDevice = await WiFiDirectDevice.FromIdAsync(deviceID); // Exception Line
}));
}
}
catch (Exception ex)
{
Logger.Data($"Exception in FromIdAsync: {ex.Message},StackTrace: {ex.StackTrace}\n\r");
}
}
仍然出现以下错误:
System.Exception
HResult=0x80640012
Message=Exception from HRESULT: 0x80640012
Source=mscorlib
StackTrace:
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at TestApp.WifiDirectPublisher.<>c__DisplayClass8_0.<<OnConnectionRequestedAsync>b__0>d.MoveNext() in D:\git\TestApp\WifiDirectPublisher.cs:line 75
我做错了什么?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。