Updated to TopShelf 3.0.105 via Nuget after updating all my projects to .NET 4.0. I did not change any of my code, so I start the host as follows:
private static void _TryRun(string fileName, string pluginDirectory, string serviceName)
{
try
{
HostFactory.Run(x =>
{
x.Service<IScheduledCommandRunner>(configurator =>
{
configurator.ConstructUsing(
name =>
_TryRunBootstrapper(fileName,
pluginDirectory,
serviceName));
configurator.WhenStarted(
runner => runner.StartRunning());
configurator.WhenStopped(
runner => runner.StopRunning());
});
x.SetServiceName(serviceName);
var displayName = GetConfigString("serviceDisplayName",
"CEO Maintenance Service");
x.SetDisplayName(displayName);
var description = GetConfigString("serviceDescription",
"Runs scheduled tasks to maintain the Image Executive CEO document server.");
x.SetDescription(description);
}
);
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
I try installing the service and auto-starting as NetworkService with the following:
CeoMaintenanceService.exe install --autostart --networkservice start
This produces the following output and error:
Configuration Result:
[Success] Name CeoMaintenanceService
[Success] DisplayName CEO Maintenance Service
[Success] Description Runs scheduled tasks to maintain the Image Executive CEO document server.
[Success] ServiceName CeoMaintenanceService
Topshelf v3.0.105.0, .NET Framework v4.0.30319.18010
Running a transacted installation.
Beginning the Install phase of the installation.
Installing CEO Maintenance Service service
Installing service CeoMaintenanceService...
Service CeoMaintenanceService has been successfully installed.
Creating EventLog source CeoMaintenanceService in log Application...
The Install phase completed successfully, and the Commit phase is beginning.
The Commit phase completed successfully.
The transacted install has completed.
Topshelf.Hosts.StartHost Error: 0 : The service failed to start., System.Invalid
OperationException: Cannot start service CeoMaintenanceService on computer '.'.
---> System.ComponentModel.Win32Exception: The service did not respond to the st
art or control request in a timely fashion
--- End of inner exception stack trace ---
at System.ServiceProcess.ServiceController.Start(String[] args)
at Topshelf.Runtime.Windows.WindowsHostEnvironment.StartService(String serviceName)
at Topshelf.Hosts.StartHost.Run()
Windows could not start the CEO Maintenance Service service on Local Computer.
Error 1053: The service did not respond to the start or control request in a timely fashion.
Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
There appears to be a lot of issues just getting the service to start after installing. I have spent much time trying to get a very simple service to start. I switched to TopShelf to eliminate maintaining a Windows Service and Console project, and it really helps things, but I am really fighting the way TopShelf handles the command line and actually starting the service. Console running works fine. I have tried so much and cannot get my service install to even start. Even with nothing in my Start(), I get the startup timeout everyone mentions. I'm almost ready to dump TopShelf if I can't get it solved within another day or so. I have had to use custom PowerShell scripts to ease the install/uninstall process as well as adding custom command line arguments to the installed service's ImagePath in the registry. TopShelf is getting there, but still nothing like having a custom Installer class and controlling it all yourself. So...still digging trying to get my service to start.
--
You received this message because you are subscribed to the Google Groups "topshelf-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topshelf-discu...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.