【问题标题】:Exception from HRESULT: 0x80640012HRESULT 异常:0x80640012
【发布时间】:2021-02-22 17:44:16
【问题描述】:

我正在尝试监听 connectionRequested 监听器,

private WiFiDirectConnectionListener _listener;
...
_listener.ConnectionRequested += ConnectionRequestedAsync;

这里是监听器回调,

private async void ConnectionRequestedAsync(WiFiDirectConnectionListener sender, WiFiDirectConnectionRequestedEventArgs args) 
{
        WiFiDirectConnectionRequest request = args.GetConnectionRequest();
        if (request != null)
        {
            try
            {
                WiFiDirectDevice _device = await WiFiDirectDevice.FromIdAsync(request.DeviceInformation.Id);
                ...
            }
            catch (Exception e)
            {
                Debug.WriteLine(string.Format("Exception::\"{0}\"", e.Message));
            }
        }
}

在日志中发现异常(用于调用WiFiDirectDevice.FromIdAsync),

Exception::"HRESULT 异常:0x80640012"

任何想法可能是什么原因?

【问题讨论】:

  • 您发布的错误编号是否正确?
  • @jdweng 是的。我已经仔细检查了。甚至在发布之前就用谷歌搜索了错误代码,但没有运气。
  • 搜索时总能找到错误号。找不到这个非常不寻常的号码。
  • 我会从 GITHUB 搜索源代码,看看你是否能找到错误字符串。
  • @Nico 我会尽力让你知道的。

标签: c# uwp wifi wifi-direct


【解决方案1】:

以下代码对我有用,

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);
        }));
    }

}
catch (Exception ex)
{
    Logger.E($"Exception in FromIdAsync: {ex.Message}, StackTrace: {ex.StackTrace}\n\r");
}

【讨论】:

    猜你喜欢
    • 2021-06-14
    • 2012-07-21
    • 2011-03-02
    • 2012-02-26
    • 2011-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多