cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
james_w
Level 3

Installing .NET Windows / NT Service

Hi,

I am new to these forums. I have built a Windows Service in CSharp and want to install and start the service as part of my install.

I use to use Installshield Express, and made a small app that the installer would call that simply installed the service and started it for me.

Now I upgraded to 2009 Pro and beleive that the installer can register and start the service for me. I have tried to label the assembly as 'installer class' in the Component section, and also made a NT Service Controller to start the service. The problem is that the service is not being registered in the first place.

Could someone provide guidance?!

Thansk is advance!
James
Labels (1)
0 Kudos
(5) Replies
Christopher_Pai
Level 16

You are most wise. 🙂

http://blog.deploymentengineering.com/2006/07/msi-vs-net.html

Get rid of the Installer class and instead look at the component advanced settings and you'll see places to describe the service installation and control behavior.

Remember to join the two based on the internal service name and that the service base image is the EXE key-file of the component.
0 Kudos
james_w
Level 3

Thanks Chris - away with the installer class it is! I'll try out adding the service through the advanced settings as suggested.

Thanks again
James
0 Kudos
Christopher_Pai
Level 16

One gotcha to watch out for and one tip.

The standard action that publishes assemblies to the GAC doesn't do it until after it tries to start services. Yes, ugly, I know. Tell it to Microsoft. 🙂

So don't reference GAC that you are deploying in your service. Install it privatly instead.

Now for a tip... first time you wire this up, tell it to create the service and start manually... don't wire up any control events. First establish that you have everything you need in place ( assemblies, app.config settings, whatever... ) and that you can deploy and start manually on a clean machine. Then set it to automatic and wire in your start commands.

This will save you a lot of pain trying to debug/profile if you encounter problems.
0 Kudos
TheTraveler
Level 8

Since you moved from IS Express to IS Pro, you will find out that there are a lot of ways to do stuff. Either in MSI projects types and Install Shield script project types. I personally like Install Shield script projects. For simple installations, MSI projects are really good, but IS script projects allows more flexibility. For example, you can us script code to Stop, Start, Remove, and Add services in code. You may be interested in looking into:

ServiceAddService
ServiceRemoveService
ServiceStartService
ServiceStopService

My best suggestion to you is try stuff. Find out what works for you and your installation.
0 Kudos
Christopher_Pai
Level 16

You can do the same thing in MSI ( those functions are InstallScript functions that can be used in an InstallScript custom action in a Basic MSI project ) but the general difference is in MSI you try to avoid scripting since you are reinventing the wheel.

Yes, you accept a certain amount of rigidness in MSI but generally it means more reliable installs that are developed faster and require less testing.
0 Kudos