Can't figure why my windows service work only in debug mode.
Only three functions used.
<System.Diagnostics.DebuggerNonUserCode()>
Shared Sub Main()
'Dim servicio As New Service1
'servicio.OnStart(Nothing)
'System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite)
WriteLog("Starting it")
Dim ServicesToRun() As System.ServiceProcess.ServiceBase
ServicesToRun = New System.ServiceProcess.ServiceBase() {New Service1}
System.ServiceProcess.ServiceBase.Run(ServicesToRun)
End Sub
Public Sub MainWorker()
While 1 = 1
Try
Dim mLoop As New Init
Catch ex As Exception
End Try
End While
End Sub
While its on debug mode it goes as a charm on method OnStart.
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
Dim T As New Thread(AddressOf MainWorker)
T.Start()
Catch ex As Exception
End Try
End Sub
But when its used without debug ( Installed and run ) it doesn't popup any error message. Status is running. But nothing happens. Not even the log message "Starting it" ...
Edit: Init class on pastebin PASTEBIN.INIT
The main problem is i should think outside the box for some reason when i put path to log file like this
It does not work because i need to enter the full path to Service_Log.txt file.