Creating and installing a windows service.

mike55

Contributor
Joined
Mar 26, 2004
Messages
727
Location
Ireland
I have created a windows service, I have also created the Setup package for this service. When I am testing the service on my development machine I use the following cmd: installutil abc.exe to install the service. I have a number of break points in my code, and have the line Debugger.Launch() in the OnStart(). Therefore when I go to services in control panel, and start my windows service, I am asked what debugger I want to use. That is grand, no problems there, and I am able to debug my code.

I then remove the line Debugger.Launch(), rebuild my project, rebuild my setup project in release mode. I then transfer the setup project files to the deployment server, and double click on release\abc.exe. This is where my problems are occuring, When I go to the services application, my application abc does not show. If I go to the add remove programs option I can see my application. Likewise if I go to the event viewer and look at the applications log I see that abc has been installed without any problem. I have tried to use the installutil command on the server with the .exe installed. However I get the following message: "Exception occured while initializing the installation. The format of the file abc.exe is invalid..."

Any suggestions on where I am going wrong?

Mike55.
 
In the end I had to copy up the setup file for my project. Once copied, I installed the application. I then had to open the command prompt and navigate to the windows folder, and the folder for version 2.0.50727. I then had the use the command "installutil" and specify the location of the .exe file i.e. c:/programfiles etc. however to get the installutil command to work I had to place the file location in quotation marks.

Mike55.
 
Instead of manually registering the service, you can automate it in your deployment package by adding the service executable as a custom action. This will automatically register/unregister the service using the ServiceInstaller and ServiceProcessInstaller you configured.
 
Back
Top