473,376 Members | 1,067 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,376 software developers and data experts.

Stopping and restarting a VB.NET Windows Service

I have a Windows Service (VB.NET) that runs 24/7. It
queries a Web service 5 to 10 times per hour. About 2 or
3 times a month, it fails. The log indicates that it
sends the request to the Web service but there is no
return from the service. Stopping and restarting the
Windows service cures the problem.

Our desire is to cure the problem with appropriate error
handling but failing that, is there an easy way to
automatically stop and restart the Windows service either
from within the service, from Windows, or from a parallel
Windows service that does nothing but monitor the primary
Windows Service to stop and restart it when necessary.

Any help, feedback, or comments would be appreciated.

Nov 20 '05 #1
7 10010
Hi Cor,

Asp ??

Regards,
Fergus
Nov 20 '05 #2
Hello Gene,

I'm no expert on this but no one else has given you a solution
yet.

I would expect a Windows Service to be able to stop itself, but
not to be able to start itself (because it wouldn't be running!).

Another Windows Service to monitor it would work but sounds like a
last-resort workaround. If you went this way I think you need to look
into the WMI classes which effect what you do manually with the
Computer Management Console.
Help topic:
ms-help://MS.MSDNVS/cpguide/html/cpconusingwmiwiththenetframework.htm
But get further advice - like I say, this is not my area.

I think the best solution, certainly from the point of view of
peace of mind, is to put your effort to dealing with the error.

You say that there is no return from your request. Some questions:

Do you know this because of a time-out or otherwise?
What happens next - does your Service crash?
Do all subsequent requests similarly fail?
Is an Exception thrown?
Are you logging everything that may be useful or just minimal
activity/status info?
Etc - whatever info you think might be relevant.

Regards,
Fergus

Nov 20 '05 #3
Hi again,

If I'd known you had done two posts on the same topic...

It's a good idea to post second thoughts as a reply to your
original query. Makes it easier for us. We don't have to ask for more
information only to find it on an earlier (but further down the page)
query. And under a different name, too!

Never mind :-)

============================
Some more thoughts.

WebService is inherited from
System.ComponentModel.MarshalByValueComponent.
This has a member GetService which is an implementor of the
IServiceProvider.
GetService has a member HttpContext.
HttpContext has all sort of goodies.

Even if this is a wrong avenue, they is a whole host of stuff to
be checked out in WebService's ancestry. You may well find somethig to
do with error handling, timeouts, connection life spab, etc.

Happy hunting,
Fergus
Nov 20 '05 #4
Cor
Fergus,
Because I asume 80% change it has to do with the net framework or IIS is
making a solution to track that for me as putting a horse after the car
(don't know if this proverb exist in the English language, but because you
too did use reckon and lives on the south westcoast from England, maybe you
uses that too). But if someone would give help here I did not say not to do
that, my advise was put your question too in the asp.net group.
Cor
Nov 20 '05 #5
Hi Cor,

Yes it may well be on the IIS side, or it may be the Windows Service side.
Let's hope he finds out.

|| putting a horse after the car

Almost there in spelling but quite different in meaning. :-)

"put the horse after the <cart>" is used for situations which are (usually
ridiculously) reversed.

Regards,
Fergus

ps. I've asked before and you missed the question, but I'm curious so I'll ask
again - what country do you come from ?
Nov 20 '05 #6
To Cor and Fergus:

Thank you for your comments. Here are some answers to
your comments.

(1) I am posting these questions to the
microsoft.public.dotnet.framework.webservices. Thanks for
the tip. I found that location by searching for "ASP.NET"
and finding the most frequently used site.

(2) Neither the Windows Service or Web Service has any
ASP.NET associated with them.

(3) I posted these separately because the problems are
independent of each other. In one case, it happens
whenever we go more than 30 minutes without a transaction
being sent by server. We have error trapping and the
system functions. It just causes an automatic
resubmission and a delay in the process (which makes the
end user wait longer than expected). During the busy time
of day there is no problem because the requests go every
10 or 15 minutes. During slower part of day, there can be
a 60 minute gap between requests.

The second problem happens sporatically perhaps once every
week or two at one location (out of 10). We have no idea
about what causes it. We have never seen it happen when
being closely monitored or tested. So far, our error
trapping has not yielded any clues and we have no idea of
how to duplicate the problem. (We only know how to fix it
(stop and restart windows service.) Who knows when it
will happen again?

Gene
-----Original Message-----
Hello Gene,

I'm no expert on this but no one else has given you a solutionyet.

I would expect a Windows Service to be able to stop itself, butnot to be able to start itself (because it wouldn't be running!).
Another Windows Service to monitor it would work but sounds like alast-resort workaround. If you went this way I think you need to lookinto the WMI classes which effect what you do manually with theComputer Management Console.
Help topic:
ms- help://MS.MSDNVS/cpguide/html/cpconusingwmiwiththenetframew
ork.htm But get further advice - like I say, this is not my area.
I think the best solution, certainly from the point of view ofpeace of mind, is to put your effort to dealing with the error.
You say that there is no return from your request. Some questions:
Do you know this because of a time-out or otherwise? What happens next - does your Service crash?
Do all subsequent requests similarly fail?
Is an Exception thrown?
Are you logging everything that may be useful or just minimalactivity/status info?
Etc - whatever info you think might be relevant.

Regards,
Fergus

.

Nov 20 '05 #7
Cor
Hi Gene,
I did wish I could help you but I cannot.
I see in no way a connection to the Vb.net language other than that a VB.DLL
is used as last part of the string.
I think that this can happen everywhere from your connection provider till
your program.
In your IIS (I doupt but it can)
In your Asp.net webserver part
In your operating system (balance load or something?)
Maybe you can write a program to check this, but I think the best part of
that will be that it helps you to find the problem.
When your program is ready I think the problem is gone.
Sorry I cannot help you, but lots of succes
Cor
Nov 20 '05 #8

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

Similar topics

5
by: CG | last post by:
Hi I have developed a Windows Service When I try to start the Service it tells me that it cannot start as there may not be any work to do When I comment out below line of code in my OnStart...
0
by: Daniel O'Brien | last post by:
Hi - any help with this would be greatly appreicated - it has already had me confused for a good few hours! I am using Visual Studio 2003 and the .NET framework 1.1. I have a C# Windows...
4
by: Keith | last post by:
I'm in the same boat as the fellow who posted this message back in August: Title : Windows Service, How does one make a service "fail" properly? Author : Ross Bennett Group :...
0
by: Glen Wolinsky | last post by:
I am creating a Windows service that will check a request queue (database) for pending requests. It will then process each individual request until completed, wait a set time interval and then...
5
by: chris.hearson | last post by:
How do I programmatically prevent a service from stopping? I want to be able to keep my service running (started), under certain conditions, when a user tries to stop it. I have tried throwing an...
6
by: D | last post by:
I have a simple file server utility that I wish to configure as a Windows service - using the examples of the Python Win32 book, I configured a class for the service, along with the main class...
4
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... Following the samples online, we implemented a windows service in .Net. Like most services, there's a worker thread actually doing stuff in the background. The problem we've run into is...
3
by: gourmet | last post by:
Hello! I need to restart the "Windows Audio Service" (audiosrv) via C#. I'm using the ServiceController Class to do this. It is no problem under XP and no problem under vista if UAC is...
10
by: archana | last post by:
Hi all, I am having one windows service which is updating to database. On 'Onstop i want to wait till current updation complete. How will i do this? Because if i write some lengthy code on...
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...
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
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...

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.