C# 使用WMI ManagementObjectSearcher缺少指令或程序集引用?
我找到了这个链接: 然而,当我在visual c#express edition 2008中尝试这段代码时,它显示:C# 使用WMI ManagementObjectSearcher缺少指令或程序集引用?,c#,windows,security,antivirus,C#,Windows,Security,Antivirus,我找到了这个链接: 然而,当我在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\Pr
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
这两行上的其他类似错误似乎很重要
代码段似乎缺少一些导入或其他内容
我正在使用Windows7。。。请帮忙
Andy您缺少对包含类型
ManagementObjectSearcher
的程序集的引用,该类型位于System.Management
命名空间中。添加这个名称空间,它应该可以工作
您必须右键单击项目->添加引用并添加System.Management程序集。创建新项目时不会自动添加系统管理
这实际上是代码中的内容。请查看此pastebin以查看我所拥有的内容:您必须添加对项目本身的引用。查看我的编辑。很好,它现在运行-但是它认为我没有安装防病毒软件,我正在运行Windows 7-假设它不受支持。您知道需要更改什么才能在windows 7下对其进行检测吗?我们可以通过稍微更改一行来对其进行排序:@“\root\SecurityCenter2”-您知道WMI的文档在哪里吗?并将其与c#一起使用?!在帖子中添加了两个链接,但你应该尝试自己搜索一下(只需键入
msdn searchphrase
,它通常只会找到msdn条目,我分别搜索了msdn WMI
和msdn WMI C#
)。