vb.net - 'Sub Main' was not found. Service management console application error? -
there possibly few things wrong below. haven't had chance test/debug code yet can't run it. stating no main method has been found. there is? i've changed shared etc. it's obvious?
it's flagging - 'sub main' not found in 'consoleapplication1.module1' error.
also main method wasn't separate class, trying stuff. i'm importing reference - system.processes. created vb.form realised didn't want form part , recreated console app (which possibly problem lies it's 1 of first console apps i've done).
code planned act on service dying. report , try , manage restart (not finished, ideas welcome).
imports system imports system.management imports system.serviceprocess imports system.diagnostics imports system.threading imports system.io module module1 public class control public sub main() 'public sub main(byval sargs() string) dim restart new rest restart.starttime = datetime.now() restart.cr20services() restart.report() end sub end class public class rest public starttime string dim logpath string = "c:\cr20\restart.txt" 'dim fileexists boolean = file.exists(strfile) dim arrcr20servicesinitialstatus new arraylist dim failedservices new arraylist dim arrcr20services new arraylist public sub cr20services() 'cr20 services arrcr20services.add("cr20 service") arrcr20services.add("cr20 router") each cr20service in arrcr20services arrcr20servicesinitialstatus.add(cr20service & " - " & cr20status(cr20service)) cr20restore(cr20service) next end sub private function cr20status(byval cr20service string) dim service servicecontroller = new servicecontroller(cr20service) return service.status.tostring end function private sub cr20restore(byval cr20service string) dim service servicecontroller = new servicecontroller(cr20service) 'dim p() system.diagnostics.process = system.diagnostics.process.getprocessesbyname("calc") if (service.status.equals(servicecontrollerstatus.stopped)) or (service.status.equals(servicecontrollerstatus.stoppending)) failedservices.add(service) service.stop() thread.sleep(10000) 'give service 10 seconds stop service.start() end if end sub
Comments
Post a Comment