【发布时间】:2010-09-27 14:45:15
【问题描述】:
我想将我的 Windows 服务“登录身份”用户的用户名/密码信息存储在 app.config 中。
所以在我的安装程序中,我试图从 app.config 中获取用户名/密码并设置属性,但在尝试安装服务时出现错误。
如果我硬编码用户名/密码,它工作正常,当我尝试访问 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();
}
}
【问题讨论】:
标签: c# .net security configuration windows-services