Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What I've done to make this work is to store the service name and display name in an app.config for my service. Then in my installer class, I load the app.config as an XmlDocument and use xpath to get the values out and apply them to ServiceInstaller.ServiceName and ServiceInstaller.DisplayName, before calling InitializeComponent(). This assumes you're not already setting these properties in InitializeComponent(), in which case, the settings from your config file will be ignored. The following code is what I'm calling from my installer class constructor, before InitializeComponent():</p> <pre><code> private void SetServiceName() { string configurationFilePath = Path.ChangeExtension(Assembly.GetExecutingAssembly().Location, "exe.config"); XmlDocument doc = new XmlDocument(); doc.Load(configurationFilePath); XmlNode serviceName = doc.SelectSingleNode("/xpath/to/your/@serviceName"); XmlNode displayName = doc.SelectSingleNode("/xpath/to/your/@displayName"); if (serviceName != null &amp;&amp; !string.IsNullOrEmpty(serviceName.Value)) { this.serviceInstaller.ServiceName = serviceName.Value; } if (displayName != null &amp;&amp; !string.IsNullOrEmpty(displayName.Value)) { this.serviceInstaller.DisplayName = displayName.Value; } } </code></pre> <p>I don't believe reading the configuration file directly from ConfigurationManager.AppSettings or something similar will work as when the installer runs, it's run in the context of InstallUtil.exe, not your service's .exe. You may be able to do something with ConfigurationManager.OpenExeConfiguration, however in my case, this didn't work as I was trying to get at a custom configuration section that was not loaded.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload