-
-
Notifications
You must be signed in to change notification settings - Fork 208
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
Win11 C# - BluetoothRadio.Default 'Operation is not supported on this platform.' #398
Comments
What I'm trying to do is find the default radio, and enable it if it's off. |
This tends to occur when your project doesn't target a specific enough TFM and the .NET Standard dll is used from the NuGet package. The consuming project needs to target net6.0-windows7.0 or net6.0-windows10.0.19041.0 or higher to pick up the Win32 or WinRT implementations respectively. |
version: Just to chime in here: I reference
So it seems that targeting Based on that it would seem that Win32 is used for all versions before 10.0.22000.0? If it's supposed to be for 10.0.19041.0 and up then maybe something is wrong with the package? I can reproduce it if I create a new blank WPF project. For my use case it would be great if 10.0.19041.0 and up used WinRT. If you'd like I can report it as a new issue if it's supposed to use WinRT. |
@perkjelsvik any reason you need WinRTNetworkStream over NetworkStream? |
Also the switch between using Win32 or WinRT should be for any Windows 10 target. But for .NET 7.0 it is built against 22000, there isn't a 19041 version. For .NET 6 you should be getting WinRT as long as your target SDK is 19041 or later. |
No, not really! I have only used it in my class to be able to easily navigate directly to the platform-specific NetworkStream. Normally I would just use
Hmm, that doesn't seem to be the case? Assuming WinRTNetworkStream should be accessible when targeting <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<RootNamespace>_32FeetTest</RootNamespace>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
<SupportedOSPlatformVersion>10.0.19041.0</SupportedOSPlatformVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="InTheHand.Net.Bluetooth" Version="4.1.40" />
</ItemGroup>
</Project> In code: using InTheHand.Net.Sockets;
BluetoothClient client = new();
var stream = client.GetStream();
var winRT = (WinRTNetworkStream)stream; // can't compile, CS0246 Inspecting the In this case the compiler flag Or is there something wrong with my setup? EDIT: It's a bit strange. When I add the same flag to the default MainWindow code-behind of the blank WPF project it clearly triggers as it should: |
Microsoft Visual Studio Community 2022
Version 17.8.3
VisualStudio.17.Release/17.8.3+34330.188
Microsoft .NET Framework
Version 4.8.09032
Installed Version: Community
Windows 11 Pro
InTheHand.Net.Bluetooth version 4.1.40 from NuGet (latest version)
BluetoothRadio.Default yields 'Operation is not supported on this platform.'
...and returns null.
ChatGPT seems to think I need BluetoothRadio.PrimaryRadio, but this is not recognized.
The text was updated successfully, but these errors were encountered: