Results 1 to 2 of 2

Thread: Service starts then fails

  1. #1
    TyB
    TyB is offline VB.NET Forum Fanatic
    .NET Framework
    .NET 3.5 (VS 2008)
    Join Date
    May 2009
    Posts
    102
    Reputation
    54

    Service starts then fails

    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.
    Code:
    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.
    Code:
    '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

  2. #2
    TyB
    TyB is offline VB.NET Forum Fanatic
    .NET Framework
    .NET 3.5 (VS 2008)
    Join Date
    May 2009
    Posts
    102
    Reputation
    54

    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking