Can't using Windows.Devices.Bluetooth namespace in worker service based application

longevity uyl 285 Reputation points
2023-12-22T03:11:07.88+00:00

I created a new worker service base application project named WorkerService1. And then I updated Program.cs as follows. But Visual Studio Community 222 build failed with "CS0246 can't find namespace Windows".

using WorkerService1;

using Windows.Devices.Bluetooth;

var builder = Host.CreateApplicationBuilder(args);

builder.Services.AddHostedService<Worker>();

var host = builder.Build();

host.Run();

Developer technologies | Visual Studio | Other
Developer technologies | C#
{count} votes

Accepted answer
  1. gekka 12,206 Reputation points MVP Volunteer Moderator
    2023-12-22T03:55:36.4833333+00:00

    Target OS and Target OS version must be set for Windows.

    20231222


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.