G
Guest
Hi Friends
I write a VB.net windows service (Service start periodically according a
Timer object) and install it using InstallUtil. The service start when the
Timer is enabled. Since I have requirement to start multiple instances of the
service using the sameSAME assembly on the same machine, I use install script
to install the service (using InstallUtil). I override the OnBeforeInstall,
OnBeforeUninstall, Install and Uninstall methods of Installer class so that I
can change the service name for each instances of service installed according
to that specified in Install script. This works and I m able to see several
services with different names but running on the same executable. However, I
have some configuration that need to be retrieved for EACH service instance
(i.e. Different config for difficult service instance). I write the
configuration to the registry for that service (This also works since the
registry has some key entry for EACH service name). However, problem comes:
I was unable to retrieve service name of each service instance. For example,
in the script I install 2 services called S1 and S2. The two services can
successfully be registered and started with the name S1 and S2. However, when
I attach the executable process (after the services have been started) to
VS.NET and examine the Me.ServiceName (and event source) field in my
executable (which inherits System.ServiceProcess.ServiceBase), it is Service1
instead of S1 or S2!! I read many articles from MSDN and it says I should set
this service name property to that I specify in serviceInstaller (which is S1
and S2 in this case), but the problem is that in my executable I only know
the service name in RUN TIME and I m unable to hardcode the service name to
the field. So I would like to know are there any ways for me to retrieve the
service name of the current executing service from my executable, which
inherits System.ServiceProcess.ServiceBase?
Many Thanks In advance and any help is highly appreciated!!!!!!!!
Tom
I write a VB.net windows service (Service start periodically according a
Timer object) and install it using InstallUtil. The service start when the
Timer is enabled. Since I have requirement to start multiple instances of the
service using the sameSAME assembly on the same machine, I use install script
to install the service (using InstallUtil). I override the OnBeforeInstall,
OnBeforeUninstall, Install and Uninstall methods of Installer class so that I
can change the service name for each instances of service installed according
to that specified in Install script. This works and I m able to see several
services with different names but running on the same executable. However, I
have some configuration that need to be retrieved for EACH service instance
(i.e. Different config for difficult service instance). I write the
configuration to the registry for that service (This also works since the
registry has some key entry for EACH service name). However, problem comes:
I was unable to retrieve service name of each service instance. For example,
in the script I install 2 services called S1 and S2. The two services can
successfully be registered and started with the name S1 and S2. However, when
I attach the executable process (after the services have been started) to
VS.NET and examine the Me.ServiceName (and event source) field in my
executable (which inherits System.ServiceProcess.ServiceBase), it is Service1
instead of S1 or S2!! I read many articles from MSDN and it says I should set
this service name property to that I specify in serviceInstaller (which is S1
and S2 in this case), but the problem is that in my executable I only know
the service name in RUN TIME and I m unable to hardcode the service name to
the field. So I would like to know are there any ways for me to retrieve the
service name of the current executing service from my executable, which
inherits System.ServiceProcess.ServiceBase?
Many Thanks In advance and any help is highly appreciated!!!!!!!!
Tom