Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. C# Service: Error 1053: The service did not respond to the start or control request in a timely fashion

C# Service: Error 1053: The service did not respond to the start or control request in a timely fashion

Scheduled Pinned Locked Moved C#
csharphelpdotnetquestionannouncement
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    temuco
    wrote on last edited by
    #1

    Hello,

    I have a problem with a self programmed windows service for .Net 6 that inherits from BackgroundService:

    namespace WooComMesserschmidt
    {
    internal class Worker : BackgroundService
    {
    private readonly HttpClient Client = new()
    private string BaseAddress = string.Empty;
    private readonly IConfiguration Configuration;
    private string ConfigFile = string.Empty;
    private readonly Dictionary _ConfigPar;
    internal static Dictionary ConfigPar = new();
    private readonly ILogger _logger;

    	public struct LogInfo
    	{
    		public ILogger? Logger;
    		public string?			LogFile;
    
    		public LogInfo(ILogger? logger, string logfile)
    		{
    			Logger	= logger;
    			LogFile	= logfile;
    		}
    	}
    
    	public static LogInfo logInfo;
    
    	public Worker(ILogger logger, IConfiguration configuration, Dictionary configpar)
    	{
    		Configuration	= configuration;
    		\_ConfigPar      = configpar;
    		\_logger         = logger;
    
    		Init();
    	}
    

    ...

    In the method "Init()" relatively extensive tasks take place (on my PC it takes about 2 seconds). If these are through, it goes on here:

    protected override async Task ExecuteAsync(CancellationToken stoppingToken)
    {
    if (int.TryParse(ConfigPar[cpQueryInterval], out int QueryInterval) == false)
    {
    QueryInterval = QueryIntervalStd;
    Log.LogInformation(logInfo, $"Abfrageintervall konnte nicht ermittelt werden. Es wird daher der Standardwert von {QueryInterval} Millisekunden verwendet. Prüfen Sie die Angaben in der Parameterdatei.");
    }

    		Log.LogInformation(logInfo, $"{Process.GetCurrentProcess().ProcessName} gestartet.");
    		Log.LogInformation(logInfo, $"Worker arbeitet mit Abfrageintervall von {QueryInterval} Millisekunden.");
    
    		while (stoppingToken.IsCancellationRequested == false)
    		{
    			await ProcessNewOrders();
    
    			await UpdateProducts();
    
    			Dhl\_Polling();
    
    			await Task.Delay(QueryInterval, stoppingToken);
    		}
    	}
    

    ...

    The service is supposed to fetch orders from an eShop every few minutes, update items and process DHL shipments.

    Well, when I start the program manually in the command line (i.e. not as a service), everything works as expected. Now I have registered the program as a service and every time I try to start the service I get the following error:

    Error 1053: The service did not respond to th

    Richard DeemingR 1 Reply Last reply
    0
    • T temuco

      Hello,

      I have a problem with a self programmed windows service for .Net 6 that inherits from BackgroundService:

      namespace WooComMesserschmidt
      {
      internal class Worker : BackgroundService
      {
      private readonly HttpClient Client = new()
      private string BaseAddress = string.Empty;
      private readonly IConfiguration Configuration;
      private string ConfigFile = string.Empty;
      private readonly Dictionary _ConfigPar;
      internal static Dictionary ConfigPar = new();
      private readonly ILogger _logger;

      	public struct LogInfo
      	{
      		public ILogger? Logger;
      		public string?			LogFile;
      
      		public LogInfo(ILogger? logger, string logfile)
      		{
      			Logger	= logger;
      			LogFile	= logfile;
      		}
      	}
      
      	public static LogInfo logInfo;
      
      	public Worker(ILogger logger, IConfiguration configuration, Dictionary configpar)
      	{
      		Configuration	= configuration;
      		\_ConfigPar      = configpar;
      		\_logger         = logger;
      
      		Init();
      	}
      

      ...

      In the method "Init()" relatively extensive tasks take place (on my PC it takes about 2 seconds). If these are through, it goes on here:

      protected override async Task ExecuteAsync(CancellationToken stoppingToken)
      {
      if (int.TryParse(ConfigPar[cpQueryInterval], out int QueryInterval) == false)
      {
      QueryInterval = QueryIntervalStd;
      Log.LogInformation(logInfo, $"Abfrageintervall konnte nicht ermittelt werden. Es wird daher der Standardwert von {QueryInterval} Millisekunden verwendet. Prüfen Sie die Angaben in der Parameterdatei.");
      }

      		Log.LogInformation(logInfo, $"{Process.GetCurrentProcess().ProcessName} gestartet.");
      		Log.LogInformation(logInfo, $"Worker arbeitet mit Abfrageintervall von {QueryInterval} Millisekunden.");
      
      		while (stoppingToken.IsCancellationRequested == false)
      		{
      			await ProcessNewOrders();
      
      			await UpdateProducts();
      
      			Dhl\_Polling();
      
      			await Task.Delay(QueryInterval, stoppingToken);
      		}
      	}
      

      ...

      The service is supposed to fetch orders from an eShop every few minutes, update items and process DHL shipments.

      Well, when I start the program manually in the command line (i.e. not as a service), everything works as expected. Now I have registered the program as a service and every time I try to start the service I get the following error:

      Error 1053: The service did not respond to th

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      That would suggest that your startup code is taking too long. You mention the Init method contains "extensive tasks" - I'd suggest moving some or all of those to the start of the ExecuteAsync method instead.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      T 2 Replies Last reply
      0
      • Richard DeemingR Richard Deeming

        That would suggest that your startup code is taking too long. You mention the Init method contains "extensive tasks" - I'd suggest moving some or all of those to the start of the ExecuteAsync method instead.


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        T Offline
        T Offline
        temuco
        wrote on last edited by
        #3

        Thank you. That's exactly what I did yesterday, but the error remained. I will try again, but now rested ;-)

        1 Reply Last reply
        0
        • Richard DeemingR Richard Deeming

          That would suggest that your startup code is taking too long. You mention the Init method contains "extensive tasks" - I'd suggest moving some or all of those to the start of the ExecuteAsync method instead.


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          T Offline
          T Offline
          temuco
          wrote on last edited by
          #4

          OK, problem solved. The error message had driven me astray and I was looking in the wrong place for the cause of the error. Now I proceeded systematically step by step: at the very beginning, the service crashes without doing anything. The error was due to the "displayname" of the service - this may be maximum 80 characters long, while I used 110 characters. I didn't know that and the error message also said something completely different. Thanks for your help! The weekend is saved! René

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups