views:

1317

answers:

4

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

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?

EDIT: 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.

A: 

Maybe its got something to do with your service account on you machine environment

Hope the help to understand your situation.

abmv
Sorry, checked that. The problem seems to be only when I run it from the msi, it works fine when I use InstallUtil -> so the parameters are fine
Grzenio
Do you have all the windows installer service packs etc...
abmv
+2  A: 

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["USERNAME"] = accountForm.txtPassword.Text;
    serviceProcessInstaller.Username = accountForm.txtServiceAccount.Text;
    Context.Parameters["PASSWORD"] = accountForm.txtServiceAccount.Text;
    serviceProcessInstaller.Account = ServiceAccount.User;
}
Grzenio
A: 

I had the SAME problem!! Thanks!!

A: 

Never mind I have a bug I thought I got it....

Joe