System.Management currently is only supported for Windows desktop applications.

Fiona 105 Reputation points
2025-08-16T08:23:30.8966667+00:00

I use ManagementObject which is in System.Management.dll(4.6.0) in a class library

The class libray 's TargetFramework is netstandard2.0.

Then I reference the class library in a service whick is based on BackgroundService,

when I run the service , there is an error :

System.Management currently is only supported for Windows desktop applications.

why ?what should i do ?

Developer technologies | .NET | .NET Runtime
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 79,601 Reputation points Volunteer Moderator
    2025-08-19T17:04:51.0166667+00:00

    while the package is .netstandard 2.0, when hosted on .net 8.0, it only works on the windows O/S. to access the windows api, it needs the .net 8.0 windows desktop runtime support.

    you could switch the top service to the desktop sdk:

    https://learn.microsoft.com/en-us/dotnet/core/project-sdk/msbuild-props-desktop

    but try setting the target framework of the top service to:

    net8.0-windows

    0 comments No comments

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.