我正在运行以下代码:
ManagementClass oMClass = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection colMObj = oMClass.GetInstances();
这是抛出这个异常:
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()
我查看了 Windows XP 上正在运行的服务,发现 Windows Management Instrumentation 服务的状态为“已启动”。我尝试重新启动该服务,但这没有任何好处。 然后,我尝试使用 ServiceController 类从我正在运行的代码中获取此服务的状态:
ServiceController wpiService = new ServiceController();
wpiService.ServiceName = "Winmgmt";
string wmiStatus = wpiService.Status.ToString();
MessageBox.Show("WMI status= " + wmiStatus);
wmiStatus 评估为“正在运行”。
我只在运行相同软件的多台机器中的一台机器上看到过这个错误。奇怪的是,机器运行了好几个月,然后突然开始出现这个错误。
关于可能导致此问题的任何线索?
最佳答案
我也遇到过这个问题。这是前面提到的解释如何修复 WMI 的在线资源之一: http://windowsxp.mvps.org/repairwmi.htm
如该页面所述,不同版本的 Windows 之间的修复方法似乎有所不同。
我在这些版本上都没有遇到这个问题,但在 Windows Embedded Standard 2009 上遇到了这个问题。由于 Windows XP Service Pack 2 与列出的操作系统最相关,因此我使用的是:
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.
关于c# - 系统.Management.ManagementException : Not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7165174/