dasMulli/dotnet-win32-service

DasMulli.Win32.ServiceUtils

hema2013 opened this issue · 4 comments

Hello,

  • I have Create a simple example (Console App .Net Core) :*

    public class ServiceHost : IWin32Service
    {
    public string ServiceName => "Test Service";

      public void Start(string[] startupArguments, ServiceStoppedCallback serviceStoppedCallback)
      {
          
      }
    
      public void Stop(){}
    

    }

static void Main(string[] args)
{
var host = new ServiceHost();
var win32Host = new Win32ServiceHost(host);
win32Host.Run();
}

  • I have install the service using the command "sc create" .
  • The Service has been installed on the windows services.
  • When I try to start it , Error Occurred
    "The Test Api Service service failed to start due to the following error:
    The service did not respond to the start or control request in a timely fashion."
  • Why This Error Occurred although I do not write any code on the start method.
    capture

what did you pass to sc.exe? what executable shown in the service details/properties in the service management console?

"Test Service" != "Test Api Service22"

@hema2013 also note that it may not work with the build output. try using dotnet publish -r win-x64 and use the the executable in the publish/ subdirectory of the output folder.
Using the build output may or may not work depending on service and system configurations (permissions).

Closing due to the OP not responding, please comment if the issue is still not resolved!