title: Windows Service
body: <p>I'm trying to write a small Windows Service in .NET 3.5, that check every 10mn or so if thee are new files in &quot;C:\demofolder&quot;, then send e-mail out. So far, I made it to here like in the following code, then there's error in Public Sub New()</p>
  <pre><code>Imports System
  Imports System.Timers
  Imports System.ServiceProcess
  Public Class TestMyService
  
      '  A timer that controls how frequenty the example writes to the
      '  event log.
      Private serviceTimer As Timer
  
      Public Sub New()
  
          '  Set the ServiceBase.ServiceName property.
          ServiceName = &quot;TestMyService Service&quot;
  
          '  Configure the level of control available on the service.
          CanStop = True
          CanPauseAndContinue = True
          CanHandleSessionChangeEvent = True
  
          '  Configure the service to log important events to the
          '  Application event log automatically.
          AutoLog = True
  
      End Sub
  
      Protected Overrides Sub OnStart(ByVal args() As String)
          ' Add code here to start your service. This method should set things
          ' in motion so your service can do its work.
      End Sub
  
      Protected Overrides Sub OnStop()
          ' Add code here to perform any tear-down necessary to stop your service.
      End Sub
  
  Public Shared Sub Main()
  
      '  Create an instance of the TestMyService class that will write
      '  an entry to the Application event log.  Pass the object to the
      '  shared ServiceBase.Run method.
      ServiceBase.Run(New TestMyService)
  
  End Sub
  
  
  End Class
  </code></pre>
  <p>I got the following error message:</p>
  <blockquote>
  <p>Sub Main' is declared more than once in 'mcWinService.TestMyService': mcWinService.TestMyService.Main(), mcWinService.TestMyService.Main()</p>
  <p>Public Shared Sub Main()' has multiple definitions with identical signatures.</p>
  <p>Public Sub New()' in designer-generated type 'mcWinService.TestMyService' should call InitializeComponent method.</p>
  </blockquote>