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.