缺少使用WMI ManagementObjectSearcher指令或程序集引用? [英] Missing directive or assembly reference using WMI ManagementObjectSearcher?

查看:2962
本文介绍了缺少使用WMI ManagementObjectSearcher指令或程序集引用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现此链接:

http://stackoverflow.com/questions/1331887/detect-antivirus-on-windows-using-c

然而,当我尝试这段代码在Visual C#速成2008年版这样说的:

However when I try this code in visual c# express edition 2008 it says :

Error 1 The type or namespace name 'ManagementObjectSearcher' could not be found 
(are you missing a using directive or an assembly reference?) 
C:\Users\Andy\Documents\Visual Studio 2008\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs 15 17 ConsoleApplication1

当中的2线,似乎重要的其他类似的错误!

Amongst other similar errors on the 2 lines which seem important!

看起来像代码段缺少一些进口的东西?

Looks like the code segment is missing some imports or something?

我使用Windows 7 ......请帮助!

I am using Windows 7... Please help!

刘德华

推荐答案

您缺少对包含类型的程序集的引用 ManagementObjectSearcher ,这是在 System.Management 命名空间。添加这个命名空间,它应该工作

You are missing a reference to the assembly containing the type ManagementObjectSearcher, which is in the System.Managementnamespace. Add this namespace and it should work.

您必须单击鼠标右键项目 - >添加引用,并添加System.Management组件。不与创建一个新的项目自动添加System.Managment。

You will have to rightclick the project -> add reference and add the System.Management assembly. System.Managment is not added automatically with the creation of a new project.

WMI参考结果
WMI + C#

这篇关于缺少使用WMI ManagementObjectSearcher指令或程序集引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆