Unable to create an instance of the WindowsService.ProjectInstaller installer ty pe. System.Reflection.TargetInvocationException: Exception has been thrown by the ta rget of an invocation. The inner exception System.NullReferenceException was thrown with the following error message: Object reference not set to an instance of an object.. An exception occurred during the Rollback phase of the System.Configuration.Inst all.AssemblyInstaller installer. System.InvalidOperationException: Unable to create an instance of the WindowsSer vice.ProjectInstaller installer type. The inner exception System.Reflection.TargetInvocationException was thrown with the following error message: Exception has been thrown by the target of an invoc ation.. The inner exception System.NullReferenceException was thrown with the following error message: Object reference not set to an instance of an object.. An exception occurred during the Rollback phase of the installation. This except ion will be ignored and the rollback will continue. However, the machine might n ot fully revert to its initial state after the rollback is complete. The Rollback phase completed successfully. The transacted install has completed. The installation failed, and the rollback has been performed.
namespace WindowsService { [RunInstaller( true )] public partial class ProjectInstaller: System.Configuration.Install.Installer { private readonly ServiceProcessInstaller _processInstaller=null; private readonly ServiceInstaller _serviceInstaller = null; public ProjectInstaller() { InitializeComponent( ); _processInstaller.Account = ServiceAccount.LocalSystem; _processInstaller.Username = null; _processInstaller.Password = null; _serviceInstaller.DisplayName = "OGSG"; _serviceInstaller.StartType = ServiceStartMode.Automatic; //must be the same as what was set in Program's constructor _serviceInstaller.ServiceName = "OGSG"; this.Installers.Add( _processInstaller ); this.Installers.Add( _serviceInstaller ); _serviceInstaller.AfterInstall += serviceInstaller1_AfterInstall; } private void serviceInstaller1_AfterInstall(object sender, InstallEventArgs e) { var sc = new ServiceController( "OGSG" ); sc.Start( ); } } }
_processInstaller
_serviceInstaller
null
NullReferenceException
InitializeComponent
serviceProcessInstaller1
serviceInstaller1
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)