Hi,
I must be missing something but have searched for hours and can't find what!
I have a working VB.net forms app which I am trying to convert to a Service. I've used the same code, below, in both. It works in the forms app but not in the service.
.....
listener = New TcpListener(Net.IPAddress.Any, Port)
listener.Start()
listenThread = New Threading.Thread(AddressOf WaitForRequest)
listenThread.IsBackground = True
listenThread.Start()
.......
Private Sub WaitForRequest()
Try
Dim recclient As New TcpClient
While True
Log("wait")
recclient = listener.AcceptTcpClient
Log("receiving")
......
(log writes the string to a file, it works in both cases)
The service is set to use an administrator user account which has network access.
The app works and when something is received logs "receiving" then continues; the service never gets past "wait"/ recclient =.
The listener is listening - if I try to start the app when the service is running I get an 'only one usage of each socket.....' error. And when I stop the service I log 'A blocking operation was interrupted by a call to WSACancelBlockingCall...' error.
I guess it's something obvious but I just can't see it!
Can anyone help? Thanks.
What I have tried:
I've tried LocalService, LocalSystem and NetworkService. NetworkService sounded promising but wouldn't run.
Various permutations of code but what's given seems to be the nearest to running - it just doesn't work though!!
There's nothing in the events log.