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

question on errror handling in windows service

Hi all,
how do i exit out(unload) of a windows service in case of an error.
so i have a code block as follows

try
{
}
catch(exception ex)
{
//log to event log
Application.exit();
}
i can do the above in a winforms application but can i do the same in
a windows service?i understand that i can add the required namespace
in service class and call Application.Exit() ...but is this the right
way to exit from a windows service?

2)assuming application.exit is okay to use in windows service...are
there any events which would be called before windows service exits?
in other words will it fire OnStop or any other event?

3)also when you call application.exit (or even when you stop windows
service form service explorer)..
would it just stop the service
OR
does it also unload the windows service class from memory....in other
words what would happen to a static variable declared in side a
windows service class?
would it get reinitialized to original value ..next time the service
is started? i am asking this because i think the constructor of the
class does not fire each time you restart the class which would mean
that class may not be unloaded from memory...so i am not sure how
static would work?
thanks
siddharth
Nov 16 '05 #1
1 1905
"sidd" <si************@hotmail.com> wrote in message
news:af*************************@posting.google.co m...
i can do the above in a winforms application but can i do the same in
a windows service?i understand that i can add the required namespace
in service class and call Application.Exit() ...but is this the right
way to exit from a windows service?
No!! :-) I can't remember the exact function but I think it's something like
this.stop.
2)assuming application.exit is okay to use in windows service...are
there any events which would be called before windows service exits?
in other words will it fire OnStop or any other event?
You should get the stop event.
3)also when you call application.exit (or even when you stop windows
service form service explorer)..
would it just stop the service


A service is just an exe, when you stop it the exe is closed like any other
application and removed from memory. All variables should be lost and all
classes should terminate. Constructor should fire again when the service is
started.

--
Michael Culley
Nov 16 '05 #2

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

Similar topics

2
by: Steven | last post by:
When I try to start a new web project in VB.Net using visual studio 2003 I get the following error: Visual Studio .Net has detected that the specified Web server is not running ASP.Net version...
9
by: אלחנן | last post by:
hi.. i don't know if this is the right group for this.. i have a small application which involves a windows service, and web services which bascally retrieves files, process them and zips them...
1
by: Natalia DeBow | last post by:
Hi, I am working on a Windows-based client-server application. I am involved in the development of the remote client modules. I am using asynchronous delegates to obtain information from...
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...
7
by: News | last post by:
Hello, I have to build a program with the future in mind and I need a bit of guidance from a guru or two. My program will start as a multi-user Windows Application built with VB.Net and using an...
3
by: bclegg | last post by:
Hi, I am trying to use a 3rd Party telephony (Intel's CT-ADE 8.3) library in a vb.net service. The way it hangs up is to raise an Event. If you build a windows Application you can write: Sub...
0
by: han zhiyang | last post by:
I have two new questions. 1. my exception handling codes works well when I synchronously call a web service,but How can I use it in asynchronously calling? I tried in the same way,but when error...
19
by: frankiespark | last post by:
Hello all, I was perusing the internet for information on threading when I came across this group. Since there seems to be a lot of good ideas and useful info I thought I'd pose a question. ...
10
by: Penelope Dramas | last post by:
Hello, I am using following code to handle unhandled exceptions in Windows Forms. Shared Sub Main() Dim GlobalExceptionHandler As New GlobalExceptionHandler AddHandler...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.