2 Replies - 385 Views - Last Post: 07 March 2018 - 07:57 AM Rate Topic: -----

#1 t3cho   User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 229
  • Joined: 27-May 14

Windows service - Debug mode / Run

Posted 06 March 2018 - 02:59 PM

Strange problem.

This service in debug mode works as a charm. But after install doesnt work as it should.

Main thing is it should write in log file its started.

 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.

        Try
            WriteLog("On start method..")
            Dim T As New Thread(AddressOf MainWorker)
            T.Start()
        Catch ex As Exception
            WriteLog("Error0 " & ex.Message)
        End Try

    End Sub

  ' The main entry point for the process
    <MTAThread()>
    <System.Diagnostics.DebuggerNonUserCode()>
    Shared Sub Main()
        WriteLog("Starting it")
        'DEBUG
        'Dim servicio As New Service1
        'servicio.onstart(Nothing)
        'System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite)

        'RUN
        Dim ServicesToRun() As System.ServiceProcess.ServiceBase
        ServicesToRun = New System.ServiceProcess.ServiceBase() {New Service1}
        System.ServiceProcess.ServiceBase.Run(ServicesToRun)

    End Sub

    Public Sub MainWorker()
        WriteLog("Starting it main")
        While 1 = 1
            Try
                Dim mLoop As New Init
            Catch ex As Exception
                WriteLog("ErrorM " & ex.Message)
            End Try
        End While
    End Sub


When i uncomment the debug mode it works and write down to log. But in RUN mode doesnt seem anything to happen.

Service is installed and in service manager it show its up and running but nothing happening

Is This A Good Question/Topic? 0
  • +

Replies To: Windows service - Debug mode / Run

#2 andrewsw   User is offline

  • RequestedRangeNotSatisfiable
  • member icon

Reputation: 6561
  • View blog
  • Posts: 26,600
  • Joined: 12-December 12

Re: Windows service - Debug mode / Run

Posted 07 March 2018 - 12:45 AM

I don't know much about this but, are you saying the main issue is it is not writing to a log file? In which case, are you sure? How are you defining and targeting the location of the log file?

Do event logs indicate some error with writing?
Was This Post Helpful? 0
  • +
  • -

#3 t3cho   User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 229
  • Joined: 27-May 14

Re: Windows service - Debug mode / Run

Posted 07 March 2018 - 07:57 AM

Doesnt popup any message in event log.

Yes log files are on correct position in same folder as service ( which is installed on PC ).
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1