Service starts then fails

TyB

Well-known member
Joined
May 14, 2009
Messages
102
Programming Experience
3-5
I have a service that I created. The first thing it does is write a line to a text file. It is then suppose to run some functions that are in classes. The service starts then an error box comes up that the service failed stopped and that some services stop when the processing finishes. The main code never even runs and I cannot figure out why.

This is the beginning of the code. It runs.
VB.NET:
Protected Overrides Sub OnStart(ByVal args() As String)
        ' Add code here to start your service. This method should set things
        ' in motion so your service can do its work.

        'Write event to ErrLog.txt
        Dim oLog As New System.IO.StreamWriter("C:\MyService\ErrLog.txt", True)
        oLog.WriteLine("Service Started - " & Now)

        oLog.Close()

Here is the next line that never runs.
VB.NET:
'First get information on the server and create a text file.
        Dim clsTemp As New clsServer
        Dim clsServers As New List(Of clsServer)

Can you not use classes in a Windows service?

Any thoughts would be appreciated.

Ty
 
More information

The log line is only written on the first start of the service. If I start the service again it never even writes the log file line. If I uninstall the service then re-install it and run it same thing the log file is never ran. If I uninstall the service then recomplie my project and install the service again then it writes the first log. Madness.

Ty
 
Back
Top