An unhandled exception of type
'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll
Additional information: The RPC server is unavailable.
See the code below and help me out to solve this problem.
public static void Main(string[] args)
{
string strvalue;
Console.WriteLine("Welcome to Ansync webservice application");
ManagementObject Status;
Status= new ManagementObject(null,new
ManagementPath("//server/root/cimv2:Win32_Service.Name='MSSQLServer'"),null);
Console.WriteLine(Status["Started"].ToString());
Status.Dispose();
Console.ReadLine();
}
I need to print started if SQLServer has started or stopped otherwise