Search code examples
c#.netvisual-studiowindows-services

Running Windows Service Application without installing it


Whem I'm writing a Windows Service and just hit F5 I get the error message that I have to install it using installutil.exe and then run it. In practice this means everytime I change a line of code:

  1. compile
  2. switch to Developer Command Prompt
  3. remove old version
  4. install new version
  5. start service

That is very inconvenient. Is there a better way to do it?


Solution

  • I usually put the bulk of the service implementation into a class library, and then create two "front-ends" for running it - one a service project, the other a console or windows forms application. I use the console/forms application for debugging.

    However, you should be aware of the differences in the environment between the debug experience and when running as a genuine service - e.g. you can accidentally end up dependent on running in a session with an interactive user, or (for winforms) where a message pump is running.