[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.sdk

System.Management compile error in IDE

Celtami

1/18/2003 12:30:00 AM

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;
}
}
****************************************************************************
****



2 Answers

Phil Wilson

1/18/2003 12:52:00 AM

0

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;
> }
> }
> ****************************************************************************
> ****
>
>
>


Celtami

1/18/2003 1:08:00 AM

0

That did it. Thank you.

"Phil Wilson" <phil.wilson@unisys.spamcom> wrote in message
news:ewjEuNovCHA.2732@TK2MSFTNGP09...
> 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;
> > }
> > }
> >
****************************************************************************
> > ****
> >
> >
> >
>
>