c# - 系统.Management.ManagementException : Not found

标签 c# .net windows

我正在运行以下代码:

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/

相关文章:

c - Windows 程序员转向 Linux - 编码约定

windows - 无线鼠标的 WMI 类

c# - 具有大量客户端的套接字编程中的客户端到客户端通信

c# - 在列表c#中查找下一个最高和下一个最低的数字

c# - 将 XML 反序列化为 Dictionary<string, string>

c# - 将 Visual Studio 2008 升级到 2013,将 .NET 3.5 升级到 4.5.1

c# - 单元测试异步方法 : The remote hostanme could not be resolved

c++ - 没有 .NET 框架的 GUI 简单快捷?

c# - 如何从 datagridview 中的多列自动搜索?

c# - Richtextbox 在新文本前加上颜色