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
Post a Comment