title: 'Sub Main' was not found. Service management console application error?
body: <p>There is possibly a few things wrong with the below. Haven't had a chance to test/debug the code yet as can't run it. It stating that no main method has been found. But there is? i've even changed it to shared etc. It's probably something obvious?</p>
  
  <p>It's flagging - 'Sub Main' was not found in 'ConsoleApplication1.Module1' error.</p>
  
  <p>Also the main method wasn't always a separate class, I was just trying stuff. I'm importing a reference  - system.processes. Was initially created as a vb.form but realised i didn't want the form part and recreated as a console app (which is very possibly where the problem lies as it's one of the first console apps i've done). </p>
  
  <p>Code is basically planned to act on a service dying. Report and try and manage the restart (not finished, ideas welcome).</p>
  
  <pre><code>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() As String)
          Dim restart As New Rest
  
          restart.startTime = DateTime.Now()
          restart.cr20Services()
          restart.Report()
      End Sub
  
  End Class
  
  Public Class Rest
      public startTime As String
      Dim logPath As String = "C:\cr20\restart.txt"
      'Dim fileExists As Boolean = File.Exists(strFile)
      Dim arrcr20ServicesInitialStatus As New ArrayList
      Dim failedServices As New ArrayList
      Dim arrcr20Services As New ArrayList
  
  
      Public Sub cr20Services()
  
          'cr20 Services
          arrcr20Services.Add("cr20 service")
          arrcr20Services.Add("cr20 router")
  
  
          For Each cr20Service In arrcr20Services
  
              arrcr20ServicesInitialStatus.Add(cr20Service &amp; " - " &amp; cr20Status(cr20Service))
              cr20Restore(cr20Service)
  
          Next
  
  
      End Sub
  
      Private Function cr20Status(ByVal cr20Service As String)
  
          Dim service As ServiceController = New ServiceController(cr20Service)
  
          Return service.Status.ToString
  
  
      End Function
  
  
  
      Private Sub cr20Restore(ByVal cr20Service As String)
  
          Dim service As ServiceController = New ServiceController(cr20Service)
  
          'Dim p() As System.Diagnostics.Process = System.Diagnostics.Process.GetProcessesByName("calc") 
  
          If (service.Status.Equals(ServiceControllerStatus.Stopped)) Or (service.Status.Equals(ServiceControllerStatus.StopPending)) Then
  
              failedServices.Add(service)
              service.Stop()
              Thread.Sleep(10000)     'give service 10 seconds to stop
              service.Start()
  
          End If
  
      End Sub
  </code></pre>