469,628 Members | 1,012 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,628 developers. It's quick & easy.

Help creating Windows Service .net studio 2005

I am having problems creating a Windows Service using Visual Studio
2005.

Code as follows:-
Imports System.IO
Imports System.Net.Mail
Public Class Service1
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.
Timer1.Start()
End Sub
Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop
your service.
Timer1.Stop()
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
email()
Dim test as new streamwriter("C:\test")
End Sub
Sub email()
Dim myMessage As New MailMessage("t...@test.com",
"tom.mil...@gmail.co.uk", _
"test", "test")
Dim mysmtpclient As New SmtpClient("exchange03")
mysmtpclient.Send(myMessage)
End Sub
End Class
I have installed the service using the installutil
started the service using services manager in administritive tools
but
nothing happens.
i have tried doing various tasks within the timer tick procedure but
the service will not do anything. Am i missing something?? I know
my
code works as i have tested the code in a normal windows app. and
yes
i am uninstalling the service, rebuilding the project then
reinstlling
the service.
This is frustrating!!!!
Any help is mich appreciated.
Cheers, Tom.

Sep 4 '07 #1
2 1621

<te******@gmail.comwrote in message
news:11**********************@r29g2000hsg.googlegr oups.com...

<snipped>
>
This is frustrating!!!!
Any help is mich appreciated.

I would suspect that the Service application has terminated along the way,
and you don't know it. I'll assume you are using try/catch/blocks on code in
critical areas like on the OnStart and Onstop and any other areas needed,
along with an Event log to capture error messages.

If you are using a NT based O/S like XP, then you can enable the Messenger
Service and use the Netsend command in the code to send messages to the
machine the Service is running on. The Netsend command will pop a message
box on the screen that you will have to reply to, but it can be used to send
messages to yourself as to just where you are at in the Service code that
can help you in your debugging process.

Sep 4 '07 #2
On 4 Sep, 18:33, "Mr. Arnold" <MR. Arn...@Arnold.comwrote:
<teeja...@gmail.comwrote in message

news:11**********************@r29g2000hsg.googlegr oups.com...

<snipped>
This is frustrating!!!!
Any help is mich appreciated.
<snip>

My problem was that I was using the wrong timer. I was using the
System.Windows.Forms.Timer class rather than the System.Timers.Timer
class.
Sep 5 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Nick White [MSFT] | last post: by
9 posts views Thread by scorpion53061 | last post: by
4 posts views Thread by Ryan | last post: by
3 posts views Thread by shapper | last post: by
1 post views Thread by =?Utf-8?B?cm9zczYxMw==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.