WCF Service Still Callable When Windows Service Has Been Stopped?

Does your OnStop method look something like this: protected override void OnStop() { if (serviceHost! = null) { try { serviceHost.Close(); }catch{ //could throw an exception if it is in a bad state }finally{ serviceHost = null; } } } Second thing to check is that your OnStop is being called, it will not call stop if CanStop flag is false.

Without the try/catch/finally block (which I'll add) yes. I've put the code in the question. – Jonnster Jun 2 at 12:49 Onstop is being called.

– Jonnster Jun 2 at 13:11 I am guessing since you did not have the catch, there are no errors being logged when you stop it? – Nix Jun 2 at 13:25 no errors but I'll add the exception handling and see what happens. – Jonnster Jun 2 at 13:31 no exception is being thrown – Jonnster Jun 2 at 13:44.

I have now solved this and thought I would update with the answer. Although I doubt anyone else would be so stupid ;) I had added the reference to my client app by right clicking on the project and selecting "Add Reference" rather than "Add Service Reference". I am still not sure why this allows the service to be called when it is not running but now I have added it as a Service Reference everything works as expected.

Thanks for everyone's input.

I once spent half a day looking for a bug in my client code when the debugger was breaking on an exception in the service, plain as day... – shambulator Jun 3 at 21:31.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions