My windows service won't stop

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
 
M

Morten Wennevik [C# MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top