Grz*_*nio 8 .net c# installer web-services
我有一个安装程序类使用ServiceProcessInstaller.在构造函数的installer类中,我将它添加到安装程序:
serviceProcessInstaller = new ServiceProcessInstaller();
serviceInstaller = new ServiceInstaller();
// Add Both Installers to Project Installers Collection to be Run
Installers.AddRange(new Installer[]
{
serviceProcessInstaller,
serviceInstaller
});
Run Code Online (Sandbox Code Playgroud)
在Install方法中我设置了用户名和密码:
public override void Install(IDictionary stateSaver)
{
.... open the form, bla bla bla
serviceProcessInstaller.Password = accountForm.txtPassword.Text;
serviceProcessInstaller.Username = accountForm.txtServiceAccount.Text;
serviceProcessInstaller.Account = ServiceAccount.User;
}
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试运行它时,我得到了描述性错误消息:"帐户名和安全ID之间没有映射".我究竟做错了什么?
编辑:我测试只有当我使用msi包安装此组件时才会发生此错误.当我对它运行InstallUtil时,它工作得很好.
最后找到它:似乎有一个"功能" ServiceProcessInstaller,代码覆盖我使用上下文中的值显式提供的值.MSI安装程序将用户名设置为某个废话(我的公司名称),并ServiceProcessInstaller尝试以此用户身份安装服务,而不是我明确提供的服务.因此,解决方法是在配置中设置正确的值:
public override void Install(IDictionary stateSaver)
{
.... open the form, bla bla bla
serviceProcessInstaller.Password = accountForm.txtPassword.Text;
Context.Parameters["PASSWORD"] = accountForm.txtPassword.Text;
serviceProcessInstaller.Username = accountForm.txtServiceAccount.Text;
Context.Parameters["USERNAME"] = accountForm.txtServiceAccount.Text;
serviceProcessInstaller.Account = ServiceAccount.User;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7492 次 |
| 最近记录: |