c# - Why doesn't my service start after installation? -


i've created windows service, set start automatically. added following code installer:

    public projectinstaller()     {         initializecomponent();         serviceprocessinstaller1.afterinstall += new installeventhandler(serviceprocessinstaller1_afterinstall);      }      void serviceprocessinstaller1_afterinstall(object sender, installeventargs e)     {         try         {             var sc = new servicecontroller(serviceinstaller1.servicename);             sc.start();         }         catch         {         }     }      protected override void oncommitted(idictionary savedstate)     {         try         {             var sc = new servicecontroller(serviceinstaller1.servicename);             sc.start();         }         catch         {         }     } 

the service installed properly, never starts.

what cause of this?

perhaps need put in temporary diagnostic logging, maybe using system.io.file.writealltext();. know it's not answer you're looking for, it'll give quickest solution!

try {     var sc = new servicecontroller(serviceinstaller1.servicename);     sc.start();     system.io.file.writealltext(@"c:\temp\servicestart.txt", "service started"); } catch (exception ex) {     system.io.file.writealltext(@"c:\temp\servicestart.txt", ex.message); } 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -