0

I have a fundamental problem with my system. I implemented a WCF service that a bunch or clients are able to (un)install/start/stop.
The problem is that when I am in debug mode and stop abruptly the debugger (or if my client crashes), while the service is already installed and running, I will not be able to recompile unless the service is stopped.

What I currently do is:

  • either run some code to stop the service before doing any code change + compilation (very unpractical)
  • go into my Windows Service settings and manually stop the service (also very unpractical)

    Even worse, sometimes I cannot even stop the service at all and require to either kill it via Cmd line or simply restart my computer.

Is there a way I could get this service to be stopped when my client crashes or when stopping the debugger?
Any other approaches you may think of would also be welcome.
Maybe a better way of doing that is with a service timeout, where the client is supposed to keep on pinging the service in order to keep it alive (not too practical when step debugging though).

stackMeUp
  • 522
  • 4
  • 16
  • 1
    It seems you have production and development environtments on the same machine. If this is the case, you should really have different environments for production and development. If you dont have a dedicated machine, you could use virtual machines. This way the production requests to the services won't interfere with your development, and vice versa. – Pepelui360 Jan 20 '20 at 10:50
  • Thanks @pepelui360, but I am not sure how that helps me here :-) as I need to test and run my code on a same machine. The service is a local Windows service and has to be on the same machine as the clients. – stackMeUp Jan 20 '20 at 10:58
  • you can change you application and make it running as console or service to simplify the debug. Please check [my answer here](https://stackoverflow.com/questions/59539817/windows-service-nullreferenceexception-c-sharp/59541664#59541664). I've shown how it is possible to write an application that can be started as console or as windows service. – oleksa Jan 20 '20 at 11:17
  • Yes, I am already doing that, but that is not what I am after here :-) Another reason why the service cannot be left running is that it may lock up some hardware that another provider may need to use. In that case I have to make sure that it cannot happen in any released software. – stackMeUp Jan 20 '20 at 11:31
  • 1
    I guess that when you recompile it says "it can't be overwritten" because it's still running. I ended up having two .bat files so I can run or stop it before recompiling. It's all about `installutil` and `net start`. – Gonzo345 Jan 20 '20 at 11:44
  • @Gonzo345, yes I thought about doing something like that, but I was hopping to find a solution that also prevents the service to keep running when the client crashes. – stackMeUp Jan 20 '20 at 12:38

0 Answers0