473,385 Members | 1,834 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.

Windows service stops at error...

Hi guys,

I have a windows service which runs few timers to perform a certain task,
my code is well wrapped with "Try...Catch"s, but still whenever an error
occurs and an exception is being thrown, it executes the code in the "Catch"
section and instead of continue, the service stops.

What gives?

I want it to continue running even if an exception was cought.

Thanks!

Ori :)
Nov 21 '05 #1
5 1203
Depend on what code you have in the Catch block.

chanmm

"Ori :)" <Or*@discussions.microsoft.com> wrote in message
news:BA**********************************@microsof t.com...
Hi guys,

I have a windows service which runs few timers to perform a certain task,
my code is well wrapped with "Try...Catch"s, but still whenever an error
occurs and an exception is being thrown, it executes the code in the
"Catch"
section and instead of continue, the service stops.

What gives?

I want it to continue running even if an exception was cought.

Thanks!

Ori :)

Nov 21 '05 #2

This is a frustrating aspect of structured error
handling. Once an error is caught, it won't go back into
the code.

You can do what I have done and go back to using on error
statements:

Sub Demonstration ()
On Error GoTo Demonstration_Error

Code Statements....

Exit Sub
Demonstration_Error:

Code to handle the error....
Resume Next
End Sub

It may not be structured, but it is a lot more flexible
and it allows you to carry on.

HTH
Helen


-----Original Message-----
Hi guys,

I have a windows service which runs few timers to perform a certain task,my code is well wrapped with "Try...Catch"s, but still whenever an erroroccurs and an exception is being thrown, it executes the code in the "Catch"section and instead of continue, the service stops.

What gives?

I want it to continue running even if an exception was cought.
Thanks!

Ori :)
.

Nov 21 '05 #3
Just a call to a "WriteExMessageToFile" sub. which completes with no problem

"chanmmn" wrote:
Depend on what code you have in the Catch block.

chanmm

"Ori :)" <Or*@discussions.microsoft.com> wrote in message
news:BA**********************************@microsof t.com...
Hi guys,

I have a windows service which runs few timers to perform a certain task,
my code is well wrapped with "Try...Catch"s, but still whenever an error
occurs and an exception is being thrown, it executes the code in the
"Catch"
section and instead of continue, the service stops.

What gives?

I want it to continue running even if an exception was cought.

Thanks!

Ori :)


Nov 21 '05 #4
Thanks! will try.

Any idea why is it different than a winform application in which it does not
end the program?

"Helen Trim" wrote:

This is a frustrating aspect of structured error
handling. Once an error is caught, it won't go back into
the code.

You can do what I have done and go back to using on error
statements:

Sub Demonstration ()
On Error GoTo Demonstration_Error

Code Statements....

Exit Sub
Demonstration_Error:

Code to handle the error....
Resume Next
End Sub

It may not be structured, but it is a lot more flexible
and it allows you to carry on.

HTH
Helen


-----Original Message-----
Hi guys,

I have a windows service which runs few timers to perform

a certain task,
my code is well wrapped with "Try...Catch"s, but still

whenever an error
occurs and an exception is being thrown, it executes the

code in the "Catch"
section and instead of continue, the service stops.

What gives?

I want it to continue running even if an exception was

cought.

Thanks!

Ori :)
.

Nov 21 '05 #5
"Ori :)" <Or*@discussions.microsoft.com> wrote in message
news:BA**********************************@microsof t.com...
I have a windows service which runs few timers to perform a certain
task, my code is well wrapped with "Try...Catch"s, but still whenever
an error occurs and an exception is being thrown, it executes the code
in the "Catch" section and instead of continue, the service stops.


/Where/ is the Catch block?
Since you're using Timers, are you /always/ re-enabling them, /even if/
you catch an Exception?

HTH,
Phill W.
Nov 21 '05 #6

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

Similar topics

2
by: MatthewRoberts | last post by:
Howdy All, I have a Windows Service that often stops in its tracks with no exception and no explanation on our QA system. During testing on the development machine, it can handle any workload,...
0
by: Martijn Remmen | last post by:
I have developed a service which exposes a COM object. This service is running perfect on Windows 2000 Server and Windows 2000 Professional under the SYSTEM account. When the service is...
3
by: belgiozen | last post by:
Hi, I have a working windows service,it is looking for files on the disk and when some of the files are cupdated it calls an executable. But it takes a lot of time(about 10 minutes) to run the...
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: ...
4
by: Nathan Kovac | last post by:
I have a windows service project created with a timer that fires an event over and over. I created an installer & the service appears to install correctly. When I try to start the service I get a...
2
by: Chris Dunaway | last post by:
I am attempting to use the AppDomain.UnhandledException event in a Windows Forms app and also in a Windows Service. But the event doesn't seem to be called. In a Windows Forms app, the event IS...
1
by: Sergey Krutous | last post by:
Can you please help me to resolve the following issue: I developed a windows service. At start up (I have overriden OnStart method) it connects to a web service and if the connection fails the...
2
by: jajalc | last post by:
Hi all, WE have a windows service using .net and which uses a System.Timers.Timer..all the of code works fine..... but after a extended period of time the timer just stops firing the elasped...
41
by: pbd22 | last post by:
Hi. I know my windows service works when i run it in debug mode on my dev machine. It also works in release mode on my dev machine. But, when I move the service to a production server, it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
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
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,...

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.