找不到ManagementObjectSearcher [英] ManagementObjectSearcher not found

查看:461
本文介绍了找不到ManagementObjectSearcher的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码,它给出了错误。它无法使用System.Management找到ManagementObjectSearcher类;



我的代码



this is my code it gives error . it could not found ManagementObjectSearcher class from using System.Management;

my code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Management;
using System.Collections.Generic;
using System.Management;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\WMI", "SELECT * FROM MSStorageDriver_ATAPISmartData");

//here ManagementObjectSearcher not found

                foreach (ManagementObject queryObj in searcher.Get())
                {
                    if (queryObj["VendorSpecific"] != null)
                    {
                        byte[] arrVendorSpecific = (byte[])(queryObj["VendorSpecific"]);
                        string temp = arrVendorSpecific[115].ToString();
                    }
                }
            }
            catch (Exception)
            {

                throw;
            }

        }
    }
}





请帮帮我解决这个问题。



Please help me to slove this problem.

推荐答案

managementobject-class-not-showing-in-system-management-namespace [ ^ ]



it's一个更苗条的问题..尝试解决方案..
managementobject-class-not-showing-up-in-system-management-namespace[^]

it's a slimier kind of issue..give a try to the solutions..


右键单击您的项目=>添加参考=>框架=>勾选2项(System.Management和

System.Management.Instrumentation)。然后单击确定。祝你好运!
Right Click Your Project=> Add Reference=> Framework=> Tick 2 item ( System.Management and
System.Management.Instrumentation). And Then Click Ok. Good Luck!


这篇关于找不到ManagementObjectSearcher的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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