c# - Why Main() method is called on service start? -


i have application 1 main class overrides servicebase methods , has main() static method. want use main() method when called command line, , onstart()/onstop() when called windows service management.

i installed app service installutils when start main() method called instead of onstart() expected.

using system; using system.collections.generic; using system.io; using system.linq; using system.net; using system.text; using system.threading.tasks; using system.timers; using system.xml.serialization; using system.runtime.serialization.json; using system.threading; using system.serviceprocess; using system.configuration.install; using system.reflection;  namespace test {      class program : servicebase     {          static void main(string[] args)         {               log.error("run app");         }           protected override void onstart(string[] args)         {             log.info("starting service");         }          protected override void onstop()         {             log.info("stopping service");         }     }   } 

windows services have guilty secret. start lives plain old console applications. it's after they've started running , register service control manager they're transformed services.

as such, yes, it's correct main first entrypoint called because @ point, it's console app.

the way service registers service control manager , becomes service handled calling servicebase.run() main method (or method invokes)


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -