加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – System.Management.ManagementException:未找到

发布时间:2020-12-16 01:46:49 所属栏目:百科 来源:网络整理
导读:我正在运行以下代码: ManagementClass oMClass = new ManagementClass("Win32_NetworkAdapterConfiguration");ManagementObjectCollection colMObj = oMClass.GetInstances(); 抛出这个异常: System.Management.ManagementException: Not found at System.
我正在运行以下代码:

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%system32wbemlogssetup.log) file.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读