473,657 Members | 2,716 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 10052
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/cpconusingwmiwi ththenetframewo rk.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.Componen tModel.MarshalB yValueComponent .
This has a member GetService which is an implementor of the
IServiceProvide r.
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.publi c.dotnet.framew ork.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/cpconusingwmiwi ththenetframew
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
2605
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 event.... objEventLog.EnableRaisingEvents = Tru ....It starts fin I have the same issue when stopping the service because of below line of code in my OnStop even
0
1540
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 Service, with my own class extending from ServiceBase in the normal fashion. The service starts a remoting object (WKO and singleton) which many clients can then make calls on. Clients may also register with events on the server such that the server...
4
15881
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 : microsoft.public.dotnet.languages.csharp URL :...
0
1421
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 move on to the next one in the list. The processing routine could take 1-2 minutes to finish processing one request. My question is this: If the service is stopped while the process routine is running, how can I make sure the processing of that...
5
17421
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 exception - from OnStop(): the SCM waits for a long time, reports that the service didn't respond in a timely fashion and then leaves the status as stopping. - from Dispose(): the SCM displays an error dialog with the exception details and...
6
8086
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 functions __init__, SvcStop, and SvcDoRun (which contains my server code). After registering the service, I am able to start it with no problems. However, it never stops correctly (net stop returns "service could not be stopped") and service is left...
4
8819
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 how to get the service to exit when the worker thread has a fatal error *and* get the SCM to invoke the auto-restart configuration? The worker thread can error out while the parent thread in the server process chugs along. We can set the exit...
3
3994
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 disabled. But with enabled UAC i'm getting a "access refused" exception. I also tried to do it via console with "net start ..." but the same error appears. Three questions:
10
7529
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 onstop it fails to stop and status remain 'stopping' Later i can't do anything on that service even i can't uninstall that service.
0
8385
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8303
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8821
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8502
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8602
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1941
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.