I have created a windows service, that I am trying to deploy on the server.
And trying to install it using Command Prompt, with Administrator role.
Installer:
[RunInstaller(true)]
public partial class ProjectInstaller : System.Configuration.Install.Installer
{
public ProjectInstaller()
{
InitializeComponent();
}
protected override void OnAfterInstall(IDictionary savedState)
{
base.OnAfterInstall(savedState);
//The following code starts the services after it is installed.
using (System.ServiceProcess.ServiceController serviceController = new System.ServiceProcess.ServiceController(serviceInstaller1.ServiceName))
{
serviceController.Start();
}
}
private void serviceProcessInstaller1_AfterInstall(object sender, InstallEventArgs e)
{
//this.serviceProcessInstaller1.Account = ServiceAccount.LocalSystem;
}
private void serviceInstaller1_AfterInstall(object sender, InstallEventArgs e)
{
}
}
And it throws error as,
an exception occurred in the onafterinstall event handler
and also,
System.InvaldiOperationException: Cannot start service on Computer. etc.