You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
System.Management fails at runtime on Win10/ARM64 #59844
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:
This code worked as-is on ARM64
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
Nuklon commentedon 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 commentedon Nov 15, 2021
@daxian-dbw does the PowerShell team now own the WMI/MMI space? What API should a .NET app use today for management?
SimonCropp commentedon Feb 26, 2023
@Nuklon isnt the nuget in question System.Management: https://www.nuget.org/packages/System.Management/ ? which is actively maintained
ViktorHofer commentedon Feb 27, 2023
Closing as dupe of #81400 which has more information.