Preji dobry den, problem s novym windows service mam tento. Udelam vse podle navodu na netu. Service ma jen trivialni zahlaseni do logu ze byl spusten a zastaven. Mam udelan ProjectInstaller.vb dle navodu. Pri instalaci pres installutil probehne vse v poradku. Bohuzel, kdyz chci proces nastartovat, zahlasi> "Sluzba xyz v Local Computer byla spustena a potom ukoncena. Nektere sluzby jsou ukonceny automaticky, jestlize nejsou pouzivany jinymi sluzbami nebo programy." Jedna se o systemy Win7 Ultimate 64-bit, Win 2008 Server 64-bit, Win 2003 Server 32-bit. Zdrojak je tady>
Imports System
Imports System.Timers
Imports System.Diagnostics
Imports System.Data
Imports System.Data.OracleClient
Imports System.ServiceProcess
Public Class xyzService
Dim Timer1 As New System.Timers.Timer
Protected Overrides Sub OnStart(ByVal args() As String)
EventLog1.WriteEntry("xyz spusten " + Now())
Try
Timer1.Enabled = True
AddHandler Timer1.Elapsed, AddressOf Timer1_Tick
Timer1.Interval = 10000
Timer1.Start()
Catch ex As Exception
EventLog1.WriteEntry("Chyba: " + ex.Message + " " + Now())
End Try
End Sub
Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop your service.
EventLog1.WriteEntry("xyz zastaven " + Now())
Timer1.Stop()
End Sub
Protected Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
Timer1.Stop()
EventLog1.WriteEntry("xyz casova udalost " + Now())
Timer1.Start()
End Sub
End Class
Problem je, i kdyz vyhodim vse kolem toho Timeru a necham tam jen hlaseni pri startu a zastaveni.
|