7

我找到了这个链接:

使用 C# 在 Windows 上检测防病毒软件

但是,当我在 Visual c# express edition 2008 中尝试此代码时,它说:

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 行似乎很重要的其他类似错误中!

看起来代码段缺少一些导入或什么?

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

安迪

4

1 回答 1

25

您缺少ManagementObjectSearcherSystem.Management名称空间中包含 type 的程序集的引用。添加此命名空间,它应该可以工作。

您必须右键单击项目 -> 添加引用并添加 System.Management 程序集。System.Managment 不会随着新项目的创建而自动添加。

WMI 参考
WMI + C#

于 2010-09-11T19:43:53.750 回答