1

I'm with Microsoft Visual Studio Community 2022 (64-bit) Version 17.0.2, .Net 6.0, and I'm unable to work with the ManagementObject. Here is the fragment of code I'm testing:

using System;
using System.Management;
public class Sample
{
    public static void Main()
    {
        ManagementObject o = new ManagementObject();
        o.Path = new ManagementPath("Win32_Process.Name='calc.exe'");
    }
}

However, when I try to run the second statement, that is to say what is the object I want to work with (in this example 'calc.exe'), I get the error

System.NullReferenceException: 'Object reference not set to an instance of an object.'

I'm using System.Management.dll found in the GAC and in c:\Windows\Microsoft.NET\Framework64\v4.0.30319. I fear that there is mismach of versions, but I'm unable to find the correct version. Or perhaps that object has been discontinued in .Net 6.0. Please tell me. Thanks

0 Answers0