EDN Admin
Well-known member
<span><div style="overflow:auto;background-color:white;border:solid 1px #7f9db9;width:;height:;line-height:100% !important;font-family:Courier New;font-size:11px <table cellpadding=0 cellspacing=0 style="width:99%;margin:2px 0px 2px 0px;border-collapse:collapse;border-bottom:2px solid #eee;background-color:#fff;border-width:0px <col style="font-family:Courier New;font-size:11px;padding-left:10px;border-bottom:1px solid #F7F7F7;white-space:nowrap <tbody><tr><td style="background-color:#F7F7F7 <span class=Apple-style-span style="border-collapse:separate;font-family:Verdana;font-size:12px;line-height:normal Hi, </td></tr></tbody></table><span class=Apple-style-span style="font-family:Verdana;font-size:12px;line-height:normal I have probably just a quick question. Im new to programming in general, being a freshman in college, and Im having issues trying to use the ManagementObjectSearcher thats apart of the System.Managment. Everytime when I go to compile my program I will get this error : "Error<font class=Apple-tab-span style="white-spacere </font>1<font class=Apple-tab-span style="white-spacere </font>The type or namespace name ManagementObjectSearcher could not be found (are you missing a using directive or an assembly reference?)<font class=Apple-tab-span style="white-spacere </font>C:UsersabellDocumentsVisual Studio 2008ProjectsTestTestProgram.cs<font class=Apple-tab-span style="white-spacere </font>8<font class=Apple-tab-span style="white-spacere </font>9<font class=Apple-tab-span style="white-spacere </font>Test"
This even comes up when I put in MSDNs example code:
<span class=Apple-style-span style="font-family:Courier New;font-size:11px;line-height:11px <table cellpadding=0 cellspacing=0 style="width:99%;margin-top:2px;margin-right:0px;margin-bottom:2px;margin-left:0px;border-collapse:collapse;border-bottom-style:solid;border-bottom-color:rgb(238, 238, 238);background-color:rgb(255, 255, 255);border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px <col style="font-family:Courier New;font-size:11px;padding-left:10px;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(247, 247, 247);white-space:nowrap <tbody><tr><td><font style="font-size:11px </font><font style="color:blue using</font><font style="font-size:11px System; </font></td></tr><tr><td style="background-color:rgb(247, 247, 247) <font style="color:blue using</font><font style="font-size:11px System.Management; </font></td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247) <font style="color:blue public</font><font style="font-size:11px </font><font style="color:blue class</font><font style="font-size:11px Sample </font></td></tr><tr><td>{ </td></tr><tr><td style="background-color:rgb(247, 247, 247) <font style="color:blue public</font><font style="font-size:11px </font><font style="color:blue static</font><font style="font-size:11px </font><font style="color:blue void</font><font style="font-size:11px Main(</font><font style="color:blue string</font><font style="font-size:11px [] args) </font></td></tr><tr><td> { </td></tr><tr><td style="background-color:rgb(247, 247, 247) ManagementObjectSearcher s = </td></tr><tr><td> <font style="color:blue new</font><font style="font-size:11px ManagementObjectSearcher( </font></td></tr><tr><td style="background-color:rgb(247, 247, 247) <font style="color:blue "root\CIMV2"</font><font style="font-size:11px , </font></td></tr><tr><td> <font style="color:blue "SELECT * FROM Win32_Service"</font><font style="font-size:11px + </font></td></tr><tr><td style="background-color:rgb(247, 247, 247) <font style="color:blue " WHERE State=Running"</font><font style="font-size:11px ); </font></td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247) <font style="color:blue foreach</font><font style="font-size:11px (ManagementObject service </font><font style="color:blue in</font><font style="font-size:11px s.Get()) </font></td></tr><tr><td> { </td></tr><tr><td style="background-color:rgb(247, 247, 247) <font style="color:green // show the instance</font><font style="font-size:11px </font></td></tr><tr><td> Console.WriteLine(service.ToString()); </td></tr><tr><td style="background-color:rgb(247, 247, 247) } </td></tr><tr><td> } </td></tr><tr><td style="background-color:rgb(247, 247, 247) }
I would realy appreciate the help that anyone can offer.
Thanks,
Smerky</td></tr></tbody></table>
View the full article
This even comes up when I put in MSDNs example code:
<span class=Apple-style-span style="font-family:Courier New;font-size:11px;line-height:11px <table cellpadding=0 cellspacing=0 style="width:99%;margin-top:2px;margin-right:0px;margin-bottom:2px;margin-left:0px;border-collapse:collapse;border-bottom-style:solid;border-bottom-color:rgb(238, 238, 238);background-color:rgb(255, 255, 255);border-top-width:0px;border-right-width:0px;border-bottom-width:0px;border-left-width:0px <col style="font-family:Courier New;font-size:11px;padding-left:10px;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(247, 247, 247);white-space:nowrap <tbody><tr><td><font style="font-size:11px </font><font style="color:blue using</font><font style="font-size:11px System; </font></td></tr><tr><td style="background-color:rgb(247, 247, 247) <font style="color:blue using</font><font style="font-size:11px System.Management; </font></td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247) <font style="color:blue public</font><font style="font-size:11px </font><font style="color:blue class</font><font style="font-size:11px Sample </font></td></tr><tr><td>{ </td></tr><tr><td style="background-color:rgb(247, 247, 247) <font style="color:blue public</font><font style="font-size:11px </font><font style="color:blue static</font><font style="font-size:11px </font><font style="color:blue void</font><font style="font-size:11px Main(</font><font style="color:blue string</font><font style="font-size:11px [] args) </font></td></tr><tr><td> { </td></tr><tr><td style="background-color:rgb(247, 247, 247) ManagementObjectSearcher s = </td></tr><tr><td> <font style="color:blue new</font><font style="font-size:11px ManagementObjectSearcher( </font></td></tr><tr><td style="background-color:rgb(247, 247, 247) <font style="color:blue "root\CIMV2"</font><font style="font-size:11px , </font></td></tr><tr><td> <font style="color:blue "SELECT * FROM Win32_Service"</font><font style="font-size:11px + </font></td></tr><tr><td style="background-color:rgb(247, 247, 247) <font style="color:blue " WHERE State=Running"</font><font style="font-size:11px ); </font></td></tr><tr><td> </td></tr><tr><td style="background-color:rgb(247, 247, 247) <font style="color:blue foreach</font><font style="font-size:11px (ManagementObject service </font><font style="color:blue in</font><font style="font-size:11px s.Get()) </font></td></tr><tr><td> { </td></tr><tr><td style="background-color:rgb(247, 247, 247) <font style="color:green // show the instance</font><font style="font-size:11px </font></td></tr><tr><td> Console.WriteLine(service.ToString()); </td></tr><tr><td style="background-color:rgb(247, 247, 247) } </td></tr><tr><td> } </td></tr><tr><td style="background-color:rgb(247, 247, 247) }
I would realy appreciate the help that anyone can offer.
Thanks,
Smerky</td></tr></tbody></table>
View the full article