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

System.Management fails at runtime on Win10/ARM64 #59844

Closed
austinkinross opened this issue Sep 30, 2021 · 4 comments
Closed

System.Management fails at runtime on Win10/ARM64 #59844

austinkinross opened this issue Sep 30, 2021 · 4 comments

Comments

@austinkinross
Copy link

Code like this compiles for Win10/ARM64 with .NET 6.0 RC1:

static string GetCommandLine(Process process)
{
    using (ManagementObjectSearcher searcher = new ManagementObjectSearcher($"SELECT CommandLine FROM Win32_Process WHERE ProcessId = {process.Id}"))
    using (ManagementObjectCollection objects = searcher.Get())
    {
        return objects.Cast<ManagementBaseObject>().SingleOrDefault()?["CommandLine"]?.ToString();
    }
}

But it doesn't actually work at runtime:

System.PlatformNotSupportedException: Could not find an installation of .NET Framework v4.0.30319. System.Management requires native modules from the .NET Framework to operate.
   at System.Management.ThreadDispatch.Start()
   at System.Management.ManagementScope.Initialize()
   at System.Management.ManagementObjectSearcher.Initialize()
   at System.Management.ManagementObjectSearcher.Get()

It would have been nice if either:

  1. This code worked as-is on ARM64
  2. OR the compiler would give me a compile-time error.

As-is, this was a nasty surprise late in development while porting my x64 app to ARM64.

@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Management untriaged New issue has not been triaged by the area owner labels Sep 30, 2021
@Nuklon
Copy link

Nuklon commented Nov 13, 2021

Sadly this is due to #45143
I wish that would be reopened, the linked https://www.nuget.org/packages/Microsoft.Management.Infrastructure/ hasn't been updated since 2019 and has several issues such as also requiring .NET Framework.

Also with W11 no longer shipping wmic tool there are not a lot of alternative options left.

@danmoseley
Copy link
Member

@daxian-dbw does the PowerShell team now own the WMI/MMI space? What API should a .NET app use today for management?

@SimonCropp
Copy link
Contributor

@Nuklon isnt the nuget in question System.Management: https://www.nuget.org/packages/System.Management/ ? which is actively maintained

@ViktorHofer
Copy link
Member

Closing as dupe of #81400 which has more information.

@ghost ghost locked as resolved and limited conversation to collaborators Mar 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants