C# Windows Service - UDP listener stops service form starter -


i trying make service listens udp packet. , works fine in debug mode. when have installed services problems start. onstart() run startlistener(). when listener runs service stops, when comment out , try again works. 1053 error code pops up.

public partial class service1 : servicebase {     private const int listenport = 9;      public service1()     {         initializecomponent();              }      protected override void onstart(string[] args)     {         startlistener();     }      protected override void onstop()     {     }      private static void startlistener()     {         udpclient listener = new udpclient(listenport);         ipendpoint groupep = new ipendpoint(ipaddress.any, listenport);         try         {                 byte[] bytes = listener.receive(ref groupep);                 string mac = string.join("", bytes.skip(6).take(6).select(b => b.tostring("x2")));         }         catch (exception e)         {         }                 {             listener.close();         }     }  } 

see https://stackoverflow.com/a/649948/1736944

the onstart event should service running. isn't place actual work.

error 1053 error windows reports when onstart fails return within set timeout (the default timeout around 30 seconds).


Comments