By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,491 Members | 1,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,491 IT Pros & Developers. It's quick & easy.

How to install 2 times the same Service?

P: n/a
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
Nov 22 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Try changing ProductCode.
"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


Nov 22 '05 #2

P: n/a
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

Nov 22 '05 #3

P: n/a
Hi,

Thanks a lot alreaddy for the answer.
Where do I find the ServiceBase.ServiceName-property? I can't find it
somewhere?

And should I change these in the ServiceInstaller1_BeforeInstall event?

The fact is: sometimes I have to isntall the Service only one time,
sometimes 2, sometimes 3 or four times :) It depends on the number of
COM-ports on the computer...

Pieter

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:ee**************@TK2MSFTNGP09.phx.gbl...
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


Nov 22 '05 #4

P: n/a
Pieter,
Where do I find the ServiceBase.ServiceName-property? I can't find it
somewhere? Normally you set it in the properties when you have the designer of the
Service itself open.
And should I change these in the ServiceInstaller1_BeforeInstall event? ServiceBase.ServiceName cannot be changed in the ServiceInstaller per se, it
is a property of the service when the service runs.

The fact is: sometimes I have to isntall the Service only one time,
sometimes 2, sometimes 3 or four times :) It depends on the number of
COM-ports on the computer...
Rather then have a service for each COM-port I would probably create a
single service. Then that single service would have a single thread (or
group of threads) for each com port.

Hope this helps
Jay

"DraguVaso" <pi**********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl... Hi,

Thanks a lot alreaddy for the answer.
Where do I find the ServiceBase.ServiceName-property? I can't find it
somewhere?

And should I change these in the ServiceInstaller1_BeforeInstall event?

The fact is: sometimes I have to isntall the Service only one time,
sometimes 2, sometimes 3 or four times :) It depends on the number of
COM-ports on the computer...

Pieter

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:ee**************@TK2MSFTNGP09.phx.gbl...
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
>
>



Nov 22 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.