'System.ArgumentException' in mscorlib.ni.dll in UWP-Starter

edited July 2017 in C#
Hi,

I am getting the following exception in the line pairedDevices.Items.Add(await BluetoothLEDevice.FromIdAsync(info.Id)); of UWP-Starter.
Exception thrown: 'System.ArgumentException' in mscorlib.ni.dll.
Thanks in advance.

Comments

  • So, on modifying the code just a little bit, like this:

    BluetoothLEDevice temp = await BluetoothLEDevice.FromIdAsync(info.Id);
    pairedDevices.Items.Add(temp);

    The exception is on the line pairedDevices.Items.Add(temp);
    temp turns out to be null and the exception has a message saying "Value does not fall within the expected range"
  • edited July 2017
    So, apparently you have to enable Bluetooth on PackageManifest file.

    Do this if you are using VS by by checking Bluetooth box at: "Properties"->"Application"->"Package Manifest..."->"Capabilities"->"Bluetooth".
    Works now. Thanks:-)
  • That's odd, Bluetooth capabilities should already be enabled in the manifest file.


    What Visual Studio version are you using?
This discussion has been closed.