Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Updated 21-Aug-16 19:21pm

1 solution

Firewall issue! I didn't think it would block local access! Windows 10.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900