0

How am I supposed to install my Windows Service from my WinForms app? Everything I read says "use InstallUtil.exe, blah blah..", but they're forgetting one thing... In all the years I've known about InstallUtil.exe, not one single computer has ever had it installed. I've always had to download InstallUtil.exe and then use it to install my service.

That really isn't an acceptable thing to be asking a client/customer to do just to be able to install your service. So how does Chrome, Opera, etc, install their services? Right now, and a brand new PC, I have no Install Util, and I'm betting that 90% of people (non programmers) don't either. So how do I install my Windows Service from a winforms app without the need for any third part or external resources other than what is already provided within the .NET framework?


I have tried installing it the normal way which is described in an MSDN article on Creating Windows Services, but it always fails with no meaningful reason:

C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release>Ins tallUtil.exe "Heartbeat Monitor.exe" Microsoft (R) .NET Framework Installation utility Version 4.0.30319.33440 Copyright (C) Microsoft Corporation. All rights reserved.

Running a transacted installation.

Beginning the Install phase of the installation. See the contents of the log file for the C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe assembly's progress.

The file is located at C:\Users\Jason\Documents\Visual Studio 2015\Projects\Note s\Notes\bin\Release\Heartbeat Monitor.InstallLog. Installing assembly 'C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\ Notes\bin\Release\Heartbeat Monitor.exe'. Affected parameters are: logtoconsole = assemblypath = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Not es\bin\Release\Heartbeat Monitor.exe logfile = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bi n\Release\Heartbeat Monitor.InstallLog

An exception occurred during the Install phase. System.ArgumentOutOfRangeException: Index and length must refer to a location wi thin the string. Parameter name: length

The Rollback phase of the installation is beginning. See the contents of the log file for the C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe assembly's progress.

The file is located at C:\Users\Jason\Documents\Visual Studio 2015\Projects\Note s\Notes\bin\Release\Heartbeat Monitor.InstallLog. Rolling back assembly 'C:\Users\Jason\Documents\Visual Studio 2015\Projects\Note s\Notes\bin\Release\Heartbeat Monitor.exe'. Affected parameters are: logtoconsole = assemblypath = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Not es\bin\Release\Heartbeat Monitor.exe logfile = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bi n\Release\Heartbeat Monitor.InstallLog

The Rollback phase completed successfully.

The transacted install has completed. The installation failed, and the rollback has been performed.

C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release>

and the InstallLog file is:

Installing assembly 'C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe'. Affected parameters are: logtoconsole = assemblypath = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe logfile = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.InstallLog Rolling back assembly 'C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe'. Affected parameters are: logtoconsole = assemblypath = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe logfile = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.InstallLog Installing assembly 'C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe'. Affected parameters are: logtoconsole = assemblypath = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe logfile = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.InstallLog Rolling back assembly 'C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe'. Affected parameters are: logtoconsole = assemblypath = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe logfile = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.InstallLog An exception occurred during the Rollback phase of the System.ServiceProcess.ServiceProcessInstaller installer. System.NullReferenceException: Object reference not set to an instance of an object. An exception occurred during the Rollback phase of the installation. This exception will be ignored and the rollback will continue. However, the machine might not fully revert to its initial state after the rollback is complete. Installing assembly 'C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe'. Affected parameters are: logtoconsole = assemblypath = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe logfile = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.InstallLog Rolling back assembly 'C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe'. Affected parameters are: logtoconsole = assemblypath = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe logfile = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.InstallLog An exception occurred during the Rollback phase of the System.ServiceProcess.ServiceProcessInstaller installer. System.NullReferenceException: Object reference not set to an instance of an object. An exception occurred during the Rollback phase of the installation. This exception will be ignored and the rollback will continue. However, the machine might not fully revert to its initial state after the rollback is complete. Installing assembly 'C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe'. Affected parameters are: logtoconsole = assemblypath = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe logfile = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.InstallLog Rolling back assembly 'C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe'. Affected parameters are: logtoconsole = assemblypath = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe logfile = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.InstallLog Installing assembly 'C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe'. Affected parameters are: logtoconsole = assemblypath = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe logfile = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.InstallLog Installing service Heartbeat Monitor... Creating EventLog source Heartbeat Monitor in log Application... Rolling back assembly 'C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe'. Affected parameters are: logtoconsole = assemblypath = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe logfile = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.InstallLog Restoring event log to previous state for source Heartbeat Monitor. Installing assembly 'C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe'. Affected parameters are: logtoconsole = assemblypath = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe logfile = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.InstallLog Rolling back assembly 'C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe'. Affected parameters are: logtoconsole = assemblypath = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.exe logfile = C:\Users\Jason\Documents\Visual Studio 2015\Projects\Notes\Notes\bin\Release\Heartbeat Monitor.InstallLog

Any help will be greatly appreciated. I am completely lost here. No idea why services are so difficult to install, even when following the instructions to a T.

NDEIGU
  • 2,563
  • 2
  • 12
  • 13
  • 1
    Can you package an MSI with your application? I usually use MSIs to install my services. – dsolimano May 19 '15 at 20:23
  • @dsolimano I haven't worked with MSI's yet. If it's free, I'll do it. I usually use um.. Inno Setup to do my installations. Not sure if that supports service installations though. – NDEIGU May 19 '15 at 20:25
  • 1
    I thought InstallUtil.exe was part of the framework install. It should be located in Windows .NET folder under the framework version you are working with. Just because it isn't found when just typing into a command window doesn't mean the user doesn't have it. – TyCobb May 19 '15 at 20:27
  • `InstallUtil.exe` is indeed part of the .NET framework, and on my machine is located in `C:\Windows\Microsoft.NET`, which indicates it's part of the OS installation itself. – Ken White May 19 '15 at 20:29
  • MSI is part of Windows, there are a variety of tools like WiX or Visual Studio you can use to build them. Not sure about Inno Setup. – dsolimano May 20 '15 at 11:59

0 Answers0