dynamic windows service name

  • Thread starter Thread starter Rami Saad
  • Start date Start date
R

Rami Saad

Hi all,

I am trying to install a service using dynamic naming. I wrote values in the
configuration file, and trying to assign one of those values to a string,
and using this string as the name of the installer



<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<appSettings>

<add key="StringName" value="StringValue" />

</appSettings>

</configuration>



//Code in the service installer

str=System.Configuration.ConfigurationSettings.AppSettings["StringName"];

this.serviceInstaller1.ServiceName=str;



when using the installutil tool, I get the following exception:

An exception occurred during the Install phase.

System.ArgumentException: Must specify value for source.



Usually, if I write the string value in a normal text file, and read the
value from the file while installing (instead of reading from the
appSettings element) I don't get any exceptions and it works fine..

So what could be the reason then? and normally how can you set a dynamic
service name using the configuration file?

Thank you for your help
 
Hi,

I suspect that configuration information at standard config files might not
be available at that time.I think it becomes available when application
itself e.g the service starts (is started from Services)
 
Back
Top