0

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,

error in CMD

an exception occurred in the onafterinstall event handler

and also,

System.InvaldiOperationException: Cannot start service on Computer. etc.

Any prompt solutions?
Similar posts: Post-1, Post-2

Community
  • 1
  • 1
Vikrant
  • 4,920
  • 17
  • 48
  • 72

1 Answers1

0

That error message about the service "not responding in a timely manner" suggests that your service is broken in some way. The Start mechanism is not a fire-and-forget design, it's more like a call into your service startup code. The service is expected to exit its start code (in a timely manner) to indicate that it's running. It's likely that your start code is doing too much work inline instead of just doing basic initialization and then instantiating a thread to do the main work of the service OR it's hanging up somewhere.

Vikrant
  • 4,920
  • 17
  • 48
  • 72
PhilDW
  • 20,260
  • 1
  • 18
  • 28
  • yes, actually the service is to generate 9-10 XML files, each containing 50000 URLs. It's pretty huge operation that it hangs up in between! – Vikrant Nov 04 '16 at 05:20