Я пытаюсь написать небольшую службу Windows в .NET 3.5, которая проверяет каждые 10 минут или около того, если вы видите новые файлы в «C: \ demofolder», а затем отправляйте электронную почту. До сих пор я сделал это здесь, как в следующем коде, то есть ошибка в Public Sub New()Служба Windows
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 = "TestMyService Service"
' 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
Я получил следующее сообщение об ошибке:
Sub Main' объявляется более один раз в 'mcWinService.TestMyService': mcWinService.TestMyService.Main(), mcWinService.TestMyService.Main()
Public Shared Sub Main() 'имеет несколько определений с идентичными сигнатурами.
Открытый Sub New() 'в создаваемом конструктором типе' mcWinService.TestMyService 'должен вызывать метод InitializeComponent.
Спасибо за образец и ссылки. – Narazana