Exception instantiating 32feet.NET InTheHand.Net.Sockets.BluetoothClient on a Blazor app

35 Views Asked by At

Trying to list bluetooth available devices on a Blazor .NET 8 WebAssembly app I installed 32feet.NET Nuget package and wrote next code.

@page "/"
@using InTheHand.Net.Sockets;

@foreach(var item in items ?? new() ){
    <div> @item</div>
}

Exception: @exception.ToString()

@code {

    List<string>? items;
    Exception? exception;

    protected override void OnParametersSet(){
        try{
            items = new List<string>();
            BluetoothClient client = new BluetoothClient();
            BluetoothDeviceInfo[] devices = client.DiscoverDevicesInRange();
            foreach (BluetoothDeviceInfo d in devices)
            {
                items.Add(d.DeviceName);
            }
        } catch(Exception ex){
            exception = ex;
        }
    }
}

However, when it attempts to instantiate the new BluetoothClient() it throws next exception:

System.TypeLoadException: Could not resolve type with token 01000023 from typeref (expected class 'System.Configuration.ConfigurationSection' in assembly 'System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') at InTheHand.Net.Bluetooth.Factory.BluetoothFactory.GetStacks_inLock() at InTheHand.Net.Bluetooth.Factory.BluetoothFactory.get_Factories() at InTheHand.Net.Bluetooth.Factory.BluetoothFactory.get_Factory() at InTheHand.Net.Sockets.BluetoothClient..ctor() at BLE.Pages.Home.OnParametersSet() in C:\Users\matia\source\Workspaces\MMO\Boot\BLE\Pages\Home.razor:line 19

0

There are 0 best solutions below