ServiceProcessInstaller失败,"帐户名和安全ID之间没有映射已完成" [英] ServiceProcessInstaller fails with "No mapping between account names and security IDs was done"

查看:468
本文介绍了ServiceProcessInstaller失败,"帐户名和安全ID之间没有映射已完成"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是安装程序类 ServiceProcessInstaller 。在构造函数中的安装程序类我把它添加到安装程序:

I have an installer class using ServiceProcessInstaller. In the installer class in the constructor I add it to installers:

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

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

和安装方法,我设置的用户名和密码:

and in Install method I set the username and password:

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之间没有映射已完成。我究竟做错了什么?

when I try to run it however, I get the very descriptive error message: "No mapping between account names and security IDs was done". What am I doing wrong?

编辑:我测试了一下这个错误仅发生在我安装使用MSI软件包该组件。它工作得很好,当我运行InstallUtil反对。

I tested that this error happens only when I install this component using msi package. It works just fine when I run InstallUtil against it.

推荐答案

发现它最后:似乎有在 ServiceProcessInstaller 特征,其中$ C $ Ç覆盖我明确设置有从上下文中的值的值。 MSI安装设置用户的一些废话(我的公司名称)和 ServiceProcessInstaller 尝试安装服务作为该用户,而不是由我明确规定的之一。因此,解决方法是在配置设置正确的值:

Found it finally: there seems to be a "feature" in ServiceProcessInstaller, where the code overwrites the values I provided explicitly with the values from the context. The MSI installer set the username to some crap (my company name), and ServiceProcessInstaller tried to install the service as this user and not the one explicitly provided by me. So the workaround is to set the correct values in the config:

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

这篇关于ServiceProcessInstaller失败,"帐户名和安全ID之间没有映射已完成"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆