I want to store the username/password information of my windows service 'logon as' user in the app.config.
So in my Installer, I am trying to grab the username/password from app.config and set the property but I am getting an error when trying to install the service.
It works fine if I hard code the username/password, and fails when I try and access the app.config
public class Blah : Installer
{
public Blah()
{
ServiceProcessInstaller oServiceProcessInstaller = new ServiceProcessInstaller();
ServiceInstaller oServiceInstaller = new ServiceInstaller();
oServiceProcessInstaller.Account = ServiceAccount.User;
oServiceProcessInstaller.Username = ConfigurationManager.AppSettings["ServiceProcessUsername"].ToString();
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…