inthehand / 32feet

Personal Area Networking for .NET. Open source and professionally supported
https://inthehand.com/components/32feet/
MIT License
814 stars 205 forks source link

Bluetooth.ScanForDevicesAsync() throws 'No path specified for UNIX transport' #341

Open DevInOrbit opened 1 year ago

DevInOrbit commented 1 year ago

Using latest Nuget package and running on Windows 10, calling Bluetooth.ScanForDevicesAsync() results in this exception:

Tmds.DBus.ConnectException: 'No path specified for UNIX transport'

Target framework .NET 7 (tried 6 also) Visual Studio 2022 Tried setting target OS windows 10, 8 and 7 with same results.

Did I miss a vital configuration step or is this a valid defect. Thanks!

mischube commented 11 months ago

i ran into the same problem. temporary solution is to use <TargetFramework>net7.0-windows10.0.19041.0</TargetFramework>

msschl commented 11 months ago

My current csproj looks like this

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net7.0-windows10.0.19041.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

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

</Project>

The code like this:

// See https://aka.ms/new-console-template for more information
using InTheHand.Bluetooth;

Console.WriteLine("Hello, World!");

var discoveredDevices = await Bluetooth.ScanForDevicesAsync();

It fails with the following error

Unhandled exception. System.NotImplementedException: This functionality is not implemented in the portable version of this assembly. You should reference the NuGet package from your main application project in order to reference the platform-specific implementation.
   at InTheHand.Net.Sockets.BluetoothClient.PlatformInitialize()
   at InTheHand.Net.Sockets.BluetoothClient..ctor()
   at Program.<Main>$(String[] args) in W:\tmp\bluethooth\Program.cs:line 6
NickRimmer commented 8 months ago

Same issue on Windows 11 with .net6

Idea with net7.0-windows sdk is not working for me. I still see error with message No path specified for UNIX transport

  <PropertyGroup>
    <TargetFramework>net7.0-windows</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>
XoBoR commented 7 months ago

Hi, I'm having the same issue in Windows 11 with .net 8.0, changing the .net version does not help in my case as well.

Has anyone found a Solution or workaround for this?

LLIAMAH commented 7 months ago

+1 Win 10 .NET 8 & .NET 7

czuryk commented 6 months ago

I have the same problem, but I found temproary working solution. Also I use advice from here. Change target framework to: net7.0-windows10.0.22621.0 Set Platforms x64

Here is my csproj file:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net7.0-windows10.0.22621.0</TargetFramework>
    <Nullable>enable</Nullable>
    <UseWindowsForms>true</UseWindowsForms>
    <ImplicitUsings>enable</ImplicitUsings>
    <Platforms>x64</Platforms>
    <SupportedOSPlatformVersion>10.0.22621.0</SupportedOSPlatformVersion>
  </PropertyGroup>

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

I use Win10, VS 2022 (17.6.2).

Now I getting results from Bluetooth.ScanForDevicesAsync() without errors

morgankenyon commented 3 months ago

Similar issues, but since I'm not on .net8 and windows 11, this is my csproj file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

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

</Project>

I believe just specifying the target framework was the crucial piece in this. Most everything else doesn't really matter.

I found it odd that <TargetFramework>net8.0-windows</TargetFramework> didn't work, but unsure of the details here.

mt09sp commented 1 month ago

Nearly a year after this was raised...

If you want to know what to set for TargetFramework Have a look at the dependency for the nuget package.

Look for net7.0-windows10.0.19041 as of 4.0.36 for InTheHand.BluetoothLE