Skip to content

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

Closed

Description

@austinkinross

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.

Activity

  1. ghost added
    untriaged
    on Sep 30, 2021
  2. Nuklon commented on Nov 13, 2021

    @Nuklon

    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.

  3. danmoseley commented on Nov 15, 2021

    @danmoseley
    Contributor

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

  4. added this to the Future milestone on Jul 19, 2022
  5. ghost removed
    untriaged
    on Jul 19, 2022
  6. SimonCropp commented on Feb 26, 2023

    @SimonCropp
    Contributor
  7. ViktorHofer commented on Feb 27, 2023

    @ViktorHofer
    Member

    Closing as dupe of #81400 which has more information.

  8. ghost locked as resolved and limited conversation to collaborators on Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions