使用 WMI ManagementObjectSearcher 缺少指令或程序集引用?
我找到了这个链接:
Detect Antivirus on Windows using C#
但是,当我尝试时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
在两行中的其他类似错误中,这似乎很重要!
看起来代码段缺少一些导入或其他东西?
我正在使用 Windows 7...请帮忙!
安迪
I have found this link:
Detect Antivirus on Windows using C#
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
Amongst other similar errors on the 2 lines which seem important!
Looks like the code segment is missing some imports or something?
I am using Windows 7... Please help!
Andy
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您缺少对包含类型
ManagementObjectSearcher
的程序集的引用,该类型位于System.Management
命名空间中。添加这个命名空间,它应该可以工作。您必须右键单击该项目 ->添加引用并添加 System.Management 程序集。创建新项目时不会自动添加 System.Managment。
WMI 参考
WMI + C#
You are missing a reference to the assembly containing the type
ManagementObjectSearcher
, which is in theSystem.Management
namespace. Add this namespace and it should work.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 reference
WMI + C#