Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlatformNotSupportedException on Win11 #445

Open
MyZQL opened this issue Dec 3, 2024 · 2 comments
Open

PlatformNotSupportedException on Win11 #445

MyZQL opened this issue Dec 3, 2024 · 2 comments

Comments

@MyZQL
Copy link

MyZQL commented Dec 3, 2024

I just started a new console program to have a test, then I met the PlatformNotSupportedException when i called the ScanForDevicesAsync() method. Here is my project info:

<Project Sdk="Microsoft.NET.Sdk"> // Win11 SDK 10.0.22621

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="InTheHand.BluetoothLE" Version="4.0.37" />
  </ItemGroup>

</Project>

And my demo code:

public static void BleScanTest1()
{
    Bluetooth.AdvertisementReceived += BluetoothOnAdvertisementReceived;
    Bluetooth.ScanForDevicesAsync().GetAwaiter().GetResult();
}

Are there any prerequisites for a console program?

@gdidelot
Copy link

Hello,

I've the same issue... Have you found a work around ?

@peterfoot
Copy link
Member

In order for the correct platform implementation to be used you have to include the full targetframework - not just net6.0. The currently supported Windows platform is net7.0-windows10.0.19041 which will run on Windows 10 19041 and above. You'd have to step back to an earlier version for .NET 6.0 - Microsoft stopped supporting .NET 6.0 last November.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants