Home All Groups Group Topic Archive Search About

Help With Windows Service

Author
26 Oct 2007 6:23 PM
Charles A. Lackman
Hello,

I wrote a Windows Service is VB.NET and it works like clock work every
night.  The problems is that the driver I am using to connect to a
datasource become inactive at a period of time.  I destroy all it's
dependencies and recreate the connection every time the Windows Service
needs to retrieve the required data.  In spite of my efforts to create a new
connection to the datasource, I continually receive a communication error on
or about the 3 or 4 day (the data is retrieved every night).

The only way I have been able to get the data to pull (after I receive the
communication error) is to restart the Windows Service.

Is there a way to make the Windows Service Restart itself?

i.e..

Try

AConnection.Open
ACommand.ExecuteNonQuery
AConnection.Close
AConnection.Dispose

Catch Err as Exception
WriteToLogFile(Err.ToString)
AConnection.Close
AConnection.Dispose
Me.Restart

End try

I Found Code To Stop The Service, but once it's stopped, then how would I
start it.

Dim scm As New ServiceController(Me.ServiceName)
scm.Stop()

Chuck

Author
27 Oct 2007 1:47 AM
Alvin Bruney [MVP]
Can you check to see if you have a connection leak? make sure that you have
not exhausted your connections to the datasource by using a trace on the
datasource.

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless Author Plug
OWC Black Book 2nd Edition
Exclusively on www.lulu.com/owc
$24.99


Show quote
"Charles A. Lackman" <Char***@CreateItSoftware.net> wrote in message
news:%23eeag1$FIHA.4808@TK2MSFTNGP05.phx.gbl...
> Hello,
>
> I wrote a Windows Service is VB.NET and it works like clock work every
> night.  The problems is that the driver I am using to connect to a
> datasource become inactive at a period of time.  I destroy all it's
> dependencies and recreate the connection every time the Windows Service
> needs to retrieve the required data.  In spite of my efforts to create a
> new
> connection to the datasource, I continually receive a communication error
> on
> or about the 3 or 4 day (the data is retrieved every night).
>
> The only way I have been able to get the data to pull (after I receive the
> communication error) is to restart the Windows Service.
>
> Is there a way to make the Windows Service Restart itself?
>
> i.e..
>
> Try
>
> AConnection.Open
> ACommand.ExecuteNonQuery
> AConnection.Close
> AConnection.Dispose
>
> Catch Err as Exception
> WriteToLogFile(Err.ToString)
> AConnection.Close
> AConnection.Dispose
> Me.Restart
>
> End try
>
> I Found Code To Stop The Service, but once it's stopped, then how would I
> start it.
>
> Dim scm As New ServiceController(Me.ServiceName)
> scm.Stop()
>
> Chuck
>
>

AddThis Social Bookmark Button