473,405 Members | 2,344 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,405 software developers and data experts.

VB.Net Service will not step into timer in debug

I have written a service in VB.Net. I have installed the service using InstallUtil.
I was able to start the service, but once I attach to and try to debug the service it will not step into my Timer1_Elapsed sub.
It will only step through the OnStop Sub when I stop the service. Now I have messed with the program so much it is not even stepping through this.
I have breakpoints set on the onstart, onstop, and Timer1_Elapsed subs as well as other places it is not breaking on anything.

Could someone tell me what I might be doing wrong or give me an example of how to correctly write/debug a service that runs on a timer or something like a timer.

See my code below:
'************************************************* ************
Protected Overrides Sub OnStart(ByVal args() As String)
Timer1.Enabled = True
End Sub

Protected Overrides Sub OnStop()
Timer1.Enabled = False
End Sub

Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
Timer1.Enabled = False
Try
Dim mode As String
mode = "GET" 'just during test trying to get this to work
Dim connectstring As String
connectstring = "database=MYDATABASE;server=MYSERVER;uid=USERNAME; pwd=PASSWORD"
SqlConn.ConnectionString = connectstring
SqlConn.Open()
If mode = "GET" Then
Call GetAndProcessFile()
ElseIf mode = "PUT" Then
Call CreateAndPutFile()
End If
Catch exp As Exception
Debug.Write("An Error Occurred: " & exp.ToString())
End Try
End Sub

--------------
From : Beth
Thanks for your help :)

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>FYt2kYXJ/EStCWBDKxlrOw==</Id>
Jul 21 '05 #1
2 5018
What version of .NET are you using. I personally found 1.1 to function alot
better when debugging multi-threaded apps.

Try removing all the breakpoints except for the Timer's event.

--
Eric Marvets
Principal Consultant

the bang project

<shameless self promotion>

Email sa***@bangproject.com for Information on Our Architecture and
Mentoring Services

</shameless self promotion>
Jul 21 '05 #2
You're using the wrong timer. Check your toolbox. I don't remember which
one or the difference, except that I had the same problem, and that was the
reason.
"Beth via .NET 247" <an*******@dotnet247.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I have written a service in VB.Net. I have installed the service using InstallUtil. I was able to start the service, but once I attach to and try to debug the service it will not step into my Timer1_Elapsed sub. It will only step through the OnStop Sub when I stop the service. Now I have messed with the program so much it is not even stepping through this. I have breakpoints set on the onstart, onstop, and Timer1_Elapsed subs as well as other places it is not breaking on anything.
Could someone tell me what I might be doing wrong or give me an example of how to correctly write/debug a service that runs on a timer or something
like a timer.
See my code below:
'************************************************* ************
Protected Overrides Sub OnStart(ByVal args() As String)
Timer1.Enabled = True
End Sub

Protected Overrides Sub OnStop()
Timer1.Enabled = False
End Sub

Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed Timer1.Enabled = False
Try
Dim mode As String
mode = "GET" 'just during test trying to get this to work
Dim connectstring As String
connectstring = "database=MYDATABASE;server=MYSERVER;uid=USERNAME; pwd=PASSWORD" SqlConn.ConnectionString = connectstring
SqlConn.Open()
If mode = "GET" Then
Call GetAndProcessFile()
ElseIf mode = "PUT" Then
Call CreateAndPutFile()
End If
Catch exp As Exception
Debug.Write("An Error Occurred: " & exp.ToString())
End Try
End Sub

--------------
From : Beth
Thanks for your help :)

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>FYt2kYXJ/EStCWBDKxlrOw==</Id>

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: acool | last post by:
I managed to get my VB.NET service installed. Now I can't get it to do anything. Tell me how do you debug smething like this if you have to manually install the assembly to run it? the same code...
5
by: Lance Colton | last post by:
it only behaves as expected if i edit the service to run under the system account and enable the "allow service to interact with desktop" option. if i run without that enabled or run it under my...
2
by: Beth via .NET 247 | last post by:
I have written a service in VB.Net. I have installed the service using InstallUtil. I was able to start the service, but once I attach to and try to debug the service it will not step into my...
2
by: Trevor | last post by:
Argh! This problem is driving me nuts! Can you help? In November of 2003, I installed a web service on Windows Server 2003 built in VB.NET for v1.1.4322 of the framework. It contains a timer...
3
by: sokolo | last post by:
Hello, I wrote a windows service application however it is not working. The service is supposed to enter a new task every 5 sec within Microsoft Outlook. Here is the code for application: ...
4
by: Lemune | last post by:
Hello everyone. I'm using vb 2005. I'm creating program that run as service on windows. And in my program I need to use timer, so I'm using timer object from component. I try my source code on...
3
by: james | last post by:
Hi all. I have a service I am writing. The last step of the onLoad event is to enable a timer, however this timer never seems to fire. I have added a line of code after the timer enable line to...
2
by: steven | last post by:
hi i've got a web app that calls a web service, both of which i've written and are available on localhost. i've added a web reference in my web app to http://localhost/mywebservice. i've set a...
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
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.