gpt4 book ai didi

c# - ServiceProcessInstaller 失败并显示 "No mapping between account names and security IDs was done"

转载 作者:太空狗 更新时间:2023-10-29 18:28:29 25 4
gpt4 key购买 nike

我有一个使用 ServiceProcessInstaller 的安装程序类。在构造函数的安装程序类中,我将其添加到安装程序中:

serviceProcessInstaller = new ServiceProcessInstaller();
serviceInstaller = new ServiceInstaller();

// Add Both Installers to Project Installers Collection to be Run
Installers.AddRange(new Installer[]
{
serviceProcessInstaller,
serviceInstaller
});

在 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;
}

但是,当我尝试运行它时,我收到了非常具有描述性的错误消息:“没有完成帐户名和安全 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;
}

关于c# - ServiceProcessInstaller 失败并显示 "No mapping between account names and security IDs was done",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/643287/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com