Note that there are some explanatory texts on larger screens.

plurals
  1. POSocketException preventing use of C# TCPListener in Windows Service
    primarykey
    data
    text
    <p>I have a Windows Service that does the following when started. When running via a Console application it works fine, but once I put in a Windows Service I get the below exception. Here is what I have tried so far:</p> <ul> <li>Disabled the firewall, also tried adding explicit exclusions for the exe, port, and protocol</li> <li>Checked CAS Policy Config, shows unrestricted rights</li> <li>Configured the Service to run as an Administrator Account, Local System, Local Service, and Network Service, each with the same result</li> <li>Tried different ports</li> <li>Also tried 127.0.0.1 just to see... same issue</li> </ul> <p>This is wrecking my head, so any help would be greatly appreciated:</p> <p>The Code:</p> <pre><code>var _listener = new TcpListener(endpoint); //192.168.2.2:20000 _listener.Start(); </code></pre> <p>The resulting Exception:</p> <pre><code>Service cannot be started. System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.Bind(EndPoint localEP) at System.Net.Sockets.TcpListener.Start(Int32 backlog) at System.Net.Sockets.TcpListener.Start() at Server.RequestHandler.StartServicingRequests(IPEndPoint endpoint) at Server.Server.StartServer(String[] args) at Server.Server.OnStart(String[] args) at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload