Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

installutil completes successfully but service is not installed

Tags:

I am trying to install a windows service.

running c:\windows\microsoft.net\Framework64\v4.0.30319\InstallUtil.exe c:\foo\MyAssembly.exe

i get a nice message that all phases (install, commit) completed successfully.

(i do not get prompted to enter service credentials)

afterwards i do not see the service in services console. nothing useful in install log.

the solution is built on a 64bit box, and i am trying to install the service on a 64bit machine. however, i do not see 64bit as an option in solution properties. i did manually edit all the csproj files to select "x64" for [platform] nodes..

i can run the service out of visual studio no problem.

installer.cs

[RunInstaller(true)] public partial class Installer : System.Configuration.Install.Installer {     public Installer() {         InitializeComponent();     } } 

this is the default installer provided by visual studio.

like image 757
Sonic Soul Avatar asked Sep 11 '12 03:09

Sonic Soul


People also ask

How do I run InstallUtil?

Install using InstallUtil.exe utilityFrom the Start menu, select the Visual Studio <version> directory, then select Developer Command Prompt for VS <version>. The Developer Command Prompt for Visual Studio appears. Access the directory where your project's compiled executable file is located.

What is InstallUtil?

The Installer tool is a command-line utility that allows you to install and uninstall server resources by executing the installer components in specified assemblies. This tool works in conjunction with classes in the System. Configuration. Install namespace. This tool is automatically installed with Visual Studio.


1 Answers

You need to add some Installer objects to the Installers collection. The example here is what you want for installing a windows service. Something like

[RunInstaller(true)] public class Installer : System.Configuration.Install.Installer {     private ServiceInstaller serviceInstaller;     private ServiceProcessInstaller processInstaller;      public Installer()     {         // Instantiate installers for process and services.         processInstaller = new ServiceProcessInstaller();         serviceInstaller = new ServiceInstaller();          // The services run under the system account.         processInstaller.Account = ServiceAccount.LocalSystem;          // The services are started manually.         serviceInstaller.StartType = ServiceStartMode.Manual;          // ServiceName must equal those on ServiceBase derived classes.         serviceInstaller.ServiceName = "Hello-World Service 1";          // Add installers to collection. Order is not important.         Installers.Add(serviceInstaller);         Installers.Add(processInstaller);     } } 
like image 159
Mike Zboray Avatar answered Oct 10 '22 04:10

Mike Zboray