Zak
Zak

Reputation: 311

System.Management.ManagementException: Not found

I am running the following code:

ManagementClass oMClass = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection colMObj = oMClass.GetInstances();

which is throwing this exception:

System.Management.ManagementException: Not found 
at System.Management.ThreadDispatch.Start()
at System.Management.ManagementScope.Initialize()
at System.Management.ManagementObject.Initialize(Boolean getObject)
at System.Management.ManagementClass.GetInstances(EnumerationOptions options)
at System.Management.ManagementClass.GetInstances()

I went to check on the running services on Windows XP and found that Windows Management Instrumentation service has a status of 'Started'. I tried restarting the service but that didn't do any good. I then tried to get the status of this service from within my running code using the ServiceController class:

ServiceController wpiService = new ServiceController();
wpiService.ServiceName = "Winmgmt";
string wmiStatus = wpiService.Status.ToString();
MessageBox.Show("WMI status= " + wmiStatus);

wmiStatus evaluates to 'Running'.

I have seen this error on only one of multiple machines running the same software. What's peculiar is that the machine was running smoothly for months, and then suddenly started showing this error.

Any clue as to what might be causing this?

Upvotes: 4

Views: 26573

Answers (2)

Martin Rasmusson
Martin Rasmusson

Reputation: 121

I have also run into this issue. Here is one of the previously mentioned online resources explaining how one can fix WMI: http://windowsxp.mvps.org/repairwmi.htm

The method of repairing seems to be different between different versions of Windows as explained on that page.

I had this problem on none of these versions, but on Windows Embedded Standard 2009. Since Windows XP Service Pack 2 is closest related to the listed OSes, that is the one I used:

For Windows XP Service Pack 2

Click Start, Run and type the following command:

rundll32 wbemupgd, UpgradeRepository

This command is used to detect and repair a corrupted WMI Repository. The results are stored in the setup.log (%windir%\system32\wbem\logs\setup.log) file.

Upvotes: 5

Zak
Zak

Reputation: 311

The solution was to repair WMI on Windows XP. I don't have the detailed step by step fix (I'm not the one who implemented the fix), but my understanding is that a repository related to this service can get corrupted and there's a Windows utility that can repair it. There are several online resources on how to do this.

Upvotes: 4

Related Questions