Usually if we want to debug the windows service application to see if it is behaving as the way you want it to be, what we need to do is by installing the windows service and attaching that project to the process.
There is also another way to debug without installing it, what we need to do to obtain this kind of debugging is to create another project such as console project then copy and paste the code below.
-
Sub Main()
-
#If Not Debug Then
-
Dim servicesToRun As System.ServiceProcess.ServiceBase()
-
-
servicesToRun = New System.ServiceProcess.ServiceBase() {New MyService()}
-
System.ServiceProcess.ServiceBase.Run(servicesToRun)
-
#Else
-
Dim service As AS2Client.AS2SenderService = New MyService()
-
service.myentrysub()
-
-
System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite)
-
-
#End If
-
-
-
-
End Sub
References:
Run Windows Service as a Console program