Help needed in Windows service

reshma

Member
Joined
Mar 10, 2005
Messages
15
Programming Experience
1-3
Hi,
I am Reshma, a new member to this group. I need help on windows service.
I am trying to write a service that sends mails to employees on the birthday's by accessing data from a particular website.
I wrote the service and it executed correctly. But after some I got some error.
And now if I am trying to write a new service its not working,
Protected Overrides Sub OnStart(ByVal args() As String)
EventLog.WriteEntry(String.Format("service started"))
End Sub


Just I wrote this to test, but I am not able to start it.


If Not MyLog.SourceExists("BirthdayService") Then
MyLog.CreateEventSource("BirthdayService", "Birthday Log")
End If
MyLog.Source = "BirthdayService"
MyLog.WriteEntry(MyLog.LogDisplayName)

I wrote this in OnStart Event, again I am getting error.

Can anyone tell me how to write to a log file and is there anyway that we can debug a service step by step while running it.

Thanks
 
---Code-----
Dim logApplog As EventLog
If Not EventLog.SourceExists(_SOURCENAME) Then
EventLog.CreateEventSource(_SOURCENAME, _LOGNAME)
End If
logApplog = New EventLog(_LOGNAME)
logApplog.Source = _SOURCENAME
---/Code----
Can you please try this method of log creation ?

--
Karthikeyan Raghuraman
 
hi Kartik,

Thanks for the reply. Sorry I was little bzy these days. I will surely try ur given code and reply u back.

Regards
 
hi Kartik,

Your code is working fine. Butwhen I tried to write something into the event log, its giving the same error.
Here's the code that I have written:
*********************************************************
Dim logApplog As EventLog

If Not EventLog.SourceExists("MailService") Then

EventLog.CreateEventSource("MailService", "MailServiceLog")

End If

logApplog = New EventLog("MailServiceLog")

logApplog.Source = "MailService"

logApplog.WriteEntry("MailService Started")
********************************************************

I have written this, the service start up event. And can u please explain me abt the arguments that this Eventlog.CreateEventSource takes.

Thank you.
 
Back
Top