none
ManagementException is raised while working WMI object collection after installing windows 10 1803 update(April 25, 2019—KB4493437 (OS Build 17134.753)) RRS feed

  • Question

  • ManagementException is raised while working WMI object collection after installing windows 10 1803 update(April 25, 2019—KB4493437 (OS Build 17134.753)). Below is the sample code

    ManagementObjectCollection collection;

    string query = "select * from win32_Thread where ProcessHandle = \"" + processId + "\"";
    using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(query))
    {
        collection = searcher.Get();
    }

    foreach (ManagementObject ObjThread in collection)

    {

    ObjThread.Get()

    }

    Above code is giving ManagementException with message "Generic Failure" while iterating through ManagementObjectCollection. This is happening only on latest windows 10 1803 update (OS Build 17134.753). This code was working fine before the update. Could you please help us in resolving this issue?

    Thursday, May 9, 2019 10:56 AM

All replies

  • Hi Nagalakshmi,

    Thank you for posting here.

    For your question, you want to solve the exception after installing windows 10 1803 update.

    I have tested the following code, I could not reproduce your problem. For this situation, I suggest that you could try to update windows 10 1809.

     var procs = System.Diagnostics.Process.GetProcesses();
                int count = 1;
                int processId = 0;
                foreach (var p in procs)
                {
                    if(count==1)
                    {
                        processId = p.Id;
                    }
                    count++;
                }
                string query = "select * from win32_Thread where ProcessHandle = \"" + processId + "\"";
                try
                {
                    using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(query))
                    {
                        var collection = searcher.Get();
                        foreach (ManagementObject ObjThread in collection)
                        {
    
                            ObjThread.Get();
                            Console.WriteLine("success");
                        }
                    }
                }
                catch(Exception e)
                {
                    Console.WriteLine(e.ToString());
                }
               
                Console.ReadKey();
    

    Result:

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, May 10, 2019 8:27 AM
    Moderator