473,385 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problemes with my win Service

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
1 946
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Hardy Wang | last post by:
Hi all: I read an article from http://www.c-sharpcorner.com/Code/2003/Sept/InstallingWinServiceProgrammatically.asp about how to install a windows service programmatically. Based ont the code...
7
by: Mike | last post by:
I want to create a windows service that will monitor another window service. what i need for the service to do is, if a service is stopped I need it to start the service back up example: ...
9
by: SP | last post by:
Hi All, I wrote a windows service which is supposed to stop after specified amount of time. I am calling OnStop() after specified time. OnStop() methods executed but I dont see the service...
3
by: Jeremy S. | last post by:
On my dev machine (XP/Pro with VS.NET 2003) I have been developing a Windows Service and installing it on the local machine by opening the Visual Studio Command Prompt and then executing . Now I...
2
by: letibal | last post by:
Hello, I have written a windows service and created an installer for it. The service runs under the system accounts. When started, it launches a GUI. By default, the InteractiveProcess property...
4
by: kkt49 | last post by:
# vim: et sw=4 ts=8 sts from wxPython.wx import * import sys, os, time import pywintypes import win32serviceutil import win32service import win32event import win32process
4
by: carson | last post by:
I have written two windows services: - service A does some crunching of local data files and uploads them to a central processing computer via http. - service B monitors a manifest file on a...
20
by: =?Utf-8?B?cmtibmFpcg==?= | last post by:
I was executing the steps given in http://suppor.microsoft.com/kb/308359 for testing a sample web service application. However, the following line gives a compilation error: localhost.Service1...
5
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name?...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.