Pieter,
Short answer you can't.
Long answer: To install the service twice you would need to change:
1. The ServiceBase.ServiceName property of your service itself.
2. The ServiceInstaller.ServiceName property on the ServiceInstaller object
on your ProjectInstaller
3. Possibly any custom Performance Counters & Event Logs...
Do you always want to install 2 instances of the service or just
occasionally install 2 instances?
What I would normally do define 2 services in my assembly. The first
MyService1 inherits from System.ServiceProcess.ServiceBase and has all the
logic for both services. The Second MyService2 inherits from MyService1 and
changes the ServiceName property, plus overrides any custom Performance
Counters or Event Logs.
Then in my ProjectInstaller I would have 2 ServiceInstaller objects, one for
MyService1 & one for MyService2. Also in the Project Installer would be any
duplicate custom Performance Counters & Event Logs...
The "problem" is if both services are in a single EXE, then both are going
to be installed. If I wanted to optionally install one or both I would
define 2 EXEs and a DLL. The DLL would have MyServiceBase that inherits from
System.ServiceProcess.ServiceBase and has all the logic for both services.
The first EXE would have MyService1 inherits from MyServiceBase and changes
the ServiceName property, plus overrides any custom Performance Counters or
Event Logs. The second EXE would have MyService2 inherits from MyServiceBase
and changes the ServiceName property, plus overrides any custom Performance
Counters or Event Logs.
Alternatively you might (*might*) be able to use Dynamic Properties in the
designer to set both of the ServiceName properties, however I want to say
the ProjectInstaller is dynamically loaded under a different program, so it
won't find your app.config with the dynamic properties.
A third alternative might be to pass the service name as a CustomActionData
from the Setup project... This might be useful with the second
alternatively...
Hope this helps
Jay
"DraguVaso" <pi**********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi,
I developped a Windows Service in VB.NET (2005).
I need to have it installed two times on 1 machine. When I want to install
it a second time, the setup doesn't allow me to install it again in an
other
directory, but only to repair or remove the other version.
I get arround this by simply copying the files of the first installed in a
second directory.
But when I want to install the second service (so it would come in the
Services-list in the config panel) I can't do this, even if I rename it...
I should have somewhere the ability to change the name of a service at the
inside: somehow with a configfile that is read. I tried this using the
ServiceInstaller_BeforeInstall-event (in the ProjectInstaller), but it
doesn't seem to work...
Anybody any idea?
Thanks a lot in advance,
Pieter