у меня есть app.config
<appSettings>
<add key="ServiceName" value="HasService"/>
<add key="ServiceDisplayName" value="HasService"/>
</appSettings>
мой класс установщика сервиса
[RunInstaller(true)]
public class MyServiceInstaller : System.Configuration.Install.Installer
{
public MyServiceInstaller()
{
var process = new ServiceProcessInstaller {Account = ServiceAccount.LocalSystem};
var serviceAdmin = new ServiceInstaller
{
StartType = ServiceStartMode.Manual,
ServiceName = "HasService",
DisplayName = "HasService"
};
Installers.Add(process);
Installers.Add(serviceAdmin);
}
}
Я хочу получить имя службы из app.config.
var serviceAdmin = new ServiceInstaller
{
StartType = ServiceStartMode.Manual,
ServiceName = GetServiceNameAppConfig("ServiceName"),
DisplayName = GetServiceNameAppConfig("ServiceDisplayName")
};
public string GetServiceNameAppConfig(string serviceName)
{
//what should i write here?
}
как получить имя службы и отображаемое имя службы из файла app.config в классе MyServiceInstaller.