本文介绍了System.Management.ManagementException问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在下面code
System.Management.ManagementClass wmiNetAdapterConfiguration = new System.Management.ManagementClass("Win32_NetworkAdapterConfiguration"); System.Management.ManagementObjectCollection wmiNetAdapters = wmiNetAdapterConfiguration.GetInstances(); Log.logInfo("Net adapters:" + wmiNetAdapters.get_Count());和在一些机器上它是好的,并且在一些我收到以下错误:
and on some machines it is ok , and on some i am getting following error :
System.Management.ManagementException: Not found at System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode) at System.Management.ManagementScope.InitializeGuts(Object o) at System.Management.ManagementScope.Initialize() at System.Management.ManagementObject.Initialize(Boolean getObject) at System.Management.ManagementClass.GetInstances(EnumerationOptions options) at System.Management.ManagementClass.GetInstances()
任何想法,为什么?
Any idea why ?
推荐答案由提供的功能 System.Management 命名空间是依赖于的 WMI(Windows管理规范)服务。
我怀疑是WMI服务尚未开始被抛出该异常系统。 为了排除故障,您可以验证使用的管理工具 - >服务工具 如果这原来是这样,你可以用在code在尝试 - 抓块使用ServiceController类启动和停止相应的服务。
I suspect that the WMI service has not been started on the systems that are throwing that exception. For troubleshooting purposes, you can verify that using the Administrative Tools -> Services utility. If this turns out to be the case, you can wrap the code in a try-catch block and use the ServiceController class to start and stop the appropriate service.
更多推荐
System.Management.ManagementException问题
发布评论