System.Management.ManagementException问题

编程入门 行业动态 更新时间:2024-10-28 04:15:13
本文介绍了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问题

本文发布于:2023-11-08 22:21:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1570605.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:System   Management   ManagementException

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!