I tried to modify the code from Windows universal samples for BLE Advertisement and got the System.Runtime.InteropServices.COMException
:
private async void OnAdvertisementReceived(BluetoothLEAdvertisementWatcher watcher, BluetoothLEAdvertisementReceivedEventArgs eventArgs)
{
if (!connected)
{
StorageFolder storageFolder = KnownFolders.DocumentsLibrary;
commandFile = await storageFolder.CreateFileAsync("command_to.txt", CreationCollisionOption.OpenIfExists);
resultFile = await storageFolder.CreateFileAsync("result_from.txt", CreationCollisionOption.OpenIfExists);
BasicProperties fileProperties = await commandFile.GetBasicPropertiesAsync(); //Here I get the COMException
commandFileVersion = fileProperties.DateModified;
}
}
This method fires every time I get BLE Advertisement. And almost every time it works fine, but sometimes I get COMException
on GetBasicPropertiesAsync()
.
The whole Exception message:
- $exception {System.Runtime.InteropServices.COMException (0x8000000E): A method was called at an unexpected time.
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at g831ble.MainPage.<OnAdvertisementReceived>d__10.MoveNext()} System.Runtime.InteropServices.COMException
User contributions licensed under CC BY-SA 3.0