471,570 Members | 1,102 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,570 software developers and data experts.

wmi to access the services runnig in PC ? -error help required

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

Dec 23 '05 #1
2 1729
Care to point out WHICH line it occured on?

On top of that, are you getting this in your console application? Or
are you getting this in an ASP.NET web service? While your code is for a
console app, the first call to WriteLine is dubious.

If you are running this in ASP.NET, then by default, you are running
under the ASPNET account, which doesn't have access to the machine you are
trying to connect to, most likely.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"myclassmates" <je**********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
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

Dec 24 '05 #2

"myclassmates" <je**********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
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


It's fundamental to read the docs before you start coding, your
managementpath is wrong!

("//server/root/cimv2:Win32_Service.Name....

should read:

(@"\\server\root\cimv2:Win32_Service.Name...

Note the @ the \\ and the \ !

Willy.
Dec 24 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

63 posts views Thread by Jerome | last post: by
1 post views Thread by Bob Alston | last post: by
13 posts views Thread by evancater | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by Vinnie | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.