By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,515 Members | 1,061 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,515 IT Pros & Developers. It's quick & easy.

Problemes with my win Service

P: n/a
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

Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.

--
Carsten Thomsen
Enterprise Development with VS .NET, UML, AND MSF
http://www.apress.com/book/bookDisplay.html?bID=105
Communities - http://community.integratedsolutions.dk

"Nijazi Halimaji" <sp***@gmx.net> wrote in message
news:OZ**************@TK2MSFTNGP09.phx.gbl...
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

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.