Problemes with my win Service

N

Nijazi Halimaji

Hi

Something wont work on my simple test windows service... I made a simple
service which writes a value into a file each minute with a timer... but the
file never would be created...

Thats my code (2005)

Public Class myService

Public Sub New()

MyBase.New()

' This call is required by the Windows Form Designer.

InitializeComponent()

tmr_check.Interval = 60000

' Add any initialization after the InitializeComponent() call.

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.

tmr_check.Enabled = True

End Sub

Protected Overrides Sub OnStop()

' Add code here to perform any tear-down necessary to stop your service.

tmr_check.Enabled = False

End Sub

Private Sub tmr_check_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles tmr_check.Tick

Dim aStreamWriter As System.IO.TextWriter

aStreamWriter = New System.IO.StreamWriter("C:\tmp.txt")



aStreamWriter.Write("sdfsdfsf")

aStreamWriter.Close()

End Sub

End Class



Is there something wrong?



Nijazi Halimaji
 
C

CT

I can see that you're using the Timer control and not the Timer component
and use the Elapsed event instead of the Tick event.. Try swapping. In
addition, make your code work in a console app first, and then move it to
the Windows service project afterwards.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top