Building and Installing Windows Service Visual Studio 2008

 

You cannot just hit Run and debug your Windows Service.  That would be really cool, but it is not that hard to get it running.

Build and Install service on your pc:

Choose Build in the Menubar above and choose Build NewService.

serviceblank

This will build your executable in the bin\release folder of your project.  If you try to run the program by itself, it will not run and give you an error.  Instead you have to load the service into your computer by using InstallUtil.exe.

You can run InstallUtil.exe from the VisualStudio Command Prompt.

servicecmd

Installing:

InstallUtil “PATH_TO_YOUR_EXE.exe”

Uninstalling:

InstallUtil “PATH_TO_YOUR_EXE.exe” /U

When you run in the command window, you will see alot of text, and at the bottom it should read:

The Commit phase completed successfully. 
The transacted install has completed.

Now we have to start the service in Service Manager. –  Right click on My Computer on the Desktop, and choose Manage.

 

servicemanage

Choose Services and Applications, Services, and New Service:
servicemanager

Right click and Choose Start.

Then Go to EventViewer, Application and you should see a log for service starting, and after 10 seconds you should see your ‘Service Running” log entry
servicelog

Now you have a running Service.  Don’t forget to stop it.  You dont want to fill your Event log up!  We set the service to Automatic in Part 2, so you may want to uninstall using InstallUtil.exe to remove from your system.

Next we will build a Setup package so you can install easily on computers that are not running Visual Studio.

Services Part 4:>  Build Setup Package for your Windows Service

 

 

Programmers – Use your talents to make some money online.  Click Here to Read More

Author: Nick Jolin

My name is Nick Jolin and I'm a full time entrepreneur making a living by creating wonderful tools that help people with online marketing. Connect with me on Google+

7 thoughts on “Building and Installing Windows Service Visual Studio 2008”

  1. Hi,

    I am facing an unknown issue while I am trying to debug windows service.
    I have created service, built it in debug mode and successfully installed it using installer. My service is reflecting in services.msc but when i try to attach a debugger to it nothing happens. Break point does not get any hit.No error nothing.
    I also checked the logs. Service is started successfully and ended successfully.

    Does any one has some idea why this is happening?

Leave a Reply

Your email address will not be published. Required fields are marked *