My windows service won't stop

  • Thread starter Thread starter Andrew Falanga
  • Start date Start date
A

Andrew Falanga

Hi,

My service is very determined. As some may recall here I've been
working on a WCF service program that I'm now trying to make into a
windows service. I've managed to get things into the solution so
that, after building, I'm able to install my service using
"installutil."

To my astonishment, it even worked. However, when I stop the service,
windows tries to do its thing and then returns to me with a message
box saying that it couldn't stop the process because it doesn't return
a windows error. I'm a little confused. When I made the project from
the Windows Service template in VS, the function OnStop() was typed as
returning void. Why is windows looking for an error return? How
should services be constructed?

Since my windows service "wraps" the WCF service, my OnStart()
function calls the WCF.Open() function. Likewise, the OnStop() calls
WCF.Close(). What am I missing?

Andy
 
Hi Andy,

When you stop a service the OnStop method is expected to finish within 30
seconds. The return is still void, though. I suspect in your case it isn't
able to finish within 30 seconds, which will cause the message that the
service could not be stopped.
 
Back
Top