andrew67
asked on
console application cannt find ManagementObjectSearcher namespace
Hi everyone im trying to write a console application to find the free space etc on a hard drive however it wont run but keeps telling me that the namespace cannt be found. my code is below along with the error
using System;
using System.Collections.Generic ;
using System.Linq;
using System.Text;
using System.Management;
namespace serverInfo
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("startin g ok");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(" select * from win32_share");
Console.WriteLine("object created ok");
}
}
}
Error 2 The type or namespace name 'ManagementObjectSearcher' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\AndrewSlaughter\L ocal Settings\Application Data\Temporary Projects\serverInfo\Progra m.cs 14 53 serverInfo
using System;
using System.Collections.Generic
using System.Linq;
using System.Text;
using System.Management;
namespace serverInfo
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("startin
ManagementObjectSearcher searcher = new ManagementObjectSearcher("
Console.WriteLine("object created ok");
}
}
}
Error 2 The type or namespace name 'ManagementObjectSearcher'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
mega works a treat thanks
Not a problem, glad I was able to help. ;=)
using System.Management;
But you need to add a Reference to the System.Management.dll library.