Phil Wilson
1/18/2003 12:52:00 AM
You probably need a reference to System.Management.Dll (in your project references, in addition to
your "using" statements).
"Celtami" <cgroberts@excite.com> wrote in message news:Omo$sBovCHA.2600@TK2MSFTNGP11...
> This sample code below will not compile in the Visual Studio .NET IDE but
> will compile using the command-line (csc) compiler. Under the IDE I get the
> error:
>
> "The type or namespace name 'Management' does not exist in the class or
> namespace 'System' (are you missing an assembly reference?)"
>
> As you can see I am referencing "System.Management." Does anyone have an
> idea why the IDE cannot see System.Management? Any help would be greatly
> appreciated.
>
> ****SAMPLE CODE*************************************************************
> using System;
> using System.Management;
>
> // This sample demonstrates performing a query using
> // ManagementObjectSearcher object.
>
> class Sample_ManagementObjectSearcher
> {
> public static int Main(string[] args)
> {
> ManagementObjectSearcher searcher = new ManagementObjectSearcher("select
> * from win32_share");
> foreach (ManagementObject share in searcher.Get())
> {
> Console.WriteLine("Share = " + share["Name"]);
> }
> return 0;
> }
> }
> ****************************************************************************
> ****
>
>
>