Problem accessing WMI class win32_NetworkAdapterConfiguration

P

Paul Steele

I have some code that uses the WMI class win32_NetworkAdapterConfiguration
to access each adapter in a system. On 99% of the systems the code seems to
work. On a very few the code fails when trying to access the WMI object.
Here's the code:

ManagementClass objMC = new
ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection adapters = objMC.GetInstances();
foreach (ManagementObject adapter in adapters)
...
The call to objMC.GetInstances fails. The error message (via a try/catch) is
simple "Not found" which is basically useless. The computer in question is a
student notebook with all sorts of extras installed, but I don't see
anything obvious that would interfere with WMI. The WMI service is also
running. Google searches have so far come up dry, but I don't have a very
useful item to key my search on. Has anyone got any suggestions on what
might be causing this problem?
 
W

Willy Denoyette [MVP]

Paul Steele said:
I have some code that uses the WMI class win32_NetworkAdapterConfiguration
to access each adapter in a system. On 99% of the systems the code seems to
work. On a very few the code fails when trying to access the WMI object.
Here's the code:

ManagementClass objMC = new
ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection adapters = objMC.GetInstances();
foreach (ManagementObject adapter in adapters)
...
The call to objMC.GetInstances fails. The error message (via a try/catch)
is simple "Not found" which is basically useless. The computer in question
is a student notebook with all sorts of extras installed, but I don't see
anything obvious that would interfere with WMI. The WMI service is also
running. Google searches have so far come up dry, but I don't have a very
useful item to key my search on. Has anyone got any suggestions on what
might be causing this problem?

What OS are these failing systems running? Did you try to create an instance
of this class using Wbemtest.exe or a simple Vbscript?

Willy.
 
P

Paul Steele

I have some code that uses the WMI class win32_NetworkAdapterConfiguration
What OS are these failing systems running? Did you try to create an
instance of this class using Wbemtest.exe or a simple Vbscript?

The student in question was very keen and tracked the problem down himself.
Turned out
that his WMI database was corrupted and he found this link to fix it:

http://windowsxp.mvps.org/repairwmi.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top