Discussion:
Retrieve Windows Service ExitCode from ServiceController
(too old to reply)
E***@gmail.com
2007-06-12 00:59:04 UTC
Permalink
In a C# Application, I'm using a service controller to Start() a
service also written in .NET.

In the OnStart() of the Service I may have an occasion to Stop the
service if something goes wrong, and would like to let the application
that is attempting to start it know just what went awry.

As opposed to using something complicated like .NET remoting or some
other inter app communications, I'd like to simply set the ExitCode
value in the Service and retrieve it from the ServiceController of the
starting app.

However, I see no way to get the exit code from the ServiceController
instance that's trying to Start() the service.

Any ideas on how to get the ExitCode?

I suspect I may have to create a Process object, via
Process.GetProcessById() or GetProcessByName() and then watch for the
ExitCode there?

Thanks

Eric
Gregg Flynn
2011-09-26 15:08:37 UTC
Permalink
Were you ever able to solve this? I am in the same situation, and google-fu has not turned up anything.
Post by E***@gmail.com
In a C# Application, I'm using a service controller to Start() a
service also written in .NET.
In the OnStart() of the Service I may have an occasion to Stop the
service if something goes wrong, and would like to let the application
that is attempting to start it know just what went awry.
As opposed to using something complicated like .NET remoting or some
other inter app communications, I'd like to simply set the ExitCode
value in the Service and retrieve it from the ServiceController of the
starting app.
However, I see no way to get the exit code from the ServiceController
instance that's trying to Start() the service.
Any ideas on how to get the ExitCode?
I suspect I may have to create a Process object, via
Process.GetProcessById() or GetProcessByName() and then watch for the
ExitCode there?
Thanks
Eric
Loading...