System.InvalidOperationException: 'A method was called at an unexpected time. (Exception from HRESULT: 0x8000000E)'

0

Getting below error,

System.InvalidOperationException: 'A method was called at an unexpected time. (Exception from HRESULT: 0x8000000E)'

for below code,

        ...
        for (int retry = 0; retry <= retryCount; retry++)
        {
            if (await RequestPairDeviceAsync(_targetDeviceInformation.Pairing)) // excetion happend here
            {
                break;
            }
        }
        ...

    private static async Task<bool> RequestPairDeviceAsync(DeviceInformationPairing pairing)
    {
        DeviceInformationCustomPairing customPairing = pairing.Custom;
        customPairing.PairingRequested += OnPairingRequested;

        PairingRequested.Invoke(_targetDeviceInformation, customPairing);

        DevicePairingResult result = await customPairing.PairAsync(DevicePairingKinds.ConfirmOnly);

        if ((result.Status == DevicePairingResultStatus.Paired) || (result.Status == DevicePairingResultStatus.AlreadyPaired)){
            return true;
        }
        return false;
    }

How to resolve it?

c#
uwp
wifi-direct

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0