public void InstallService(string user, string pass) { using (AssemblyInstaller installer = new AssemblyInstaller(Path.Combine(Utils.GetApplicationPath(), Utils.GetExecutableName()), null)) { installer.UseNewContext = true; Hashtable savedState = new Hashtable(); UserPassCombination c = new UserPassCombination(); c.User = user; c.Pass = pass; _userPassCombination = c; installer.BeforeInstall += new InstallEventHandler(installer_BeforeInstall); //Rollback has to be called by user code. According msdn-doc for AssemblyInstaller.Install() is probably wrong. try { installer.Install(savedState); installer.Commit(savedState); } catch (Exception ex) { installer.Rollback(savedState); throw new InstallException(String.Format("Install failed: {0}", ex.Message), ex); } installer.BeforeInstall -= installer_BeforeInstall; } }