.NET Remoting抛出RemotingException(连接被拒绝)的原因咨询
Common Causes of System.Runtime.Remoting.RemotingException: Connection refused
Great question—let’s break down the typical scenarios that trigger this error in .NET Remoting, especially given your TCP channel-focused stack trace:
Remoting Server Isn’t Running (or Not Listening on the Expected Port)
The most straightforward cause: the .NET Remoting service hasn’t been started, or it’s configured to listen on a different port than what your client is targeting. Double-check that the server code callsRemotingConfiguration.RegisterWellKnownServiceType(or equivalent setup) with the correct port and endpoint details.Firewall/Network Security Rules Blocking the Connection
TCP connections for Remoting rely on open network ports. A local Windows Firewall, enterprise network security group, or third-party firewall could be blocking incoming/outgoing traffic on the Remoting port. Even if the server is running, the firewall will reject the client’s connection attempt outright.Unreachable Server Machine
The client might be targeting an incorrect IP address or machine name for the Remoting server, or the server machine is offline, disconnected from the network, or experiencing routing issues. In these cases, the TCP handshake can’t even reach the server, leading to a "connection refused" error.Target Port Is Occupied by Another Process
If the port the Remoting server is supposed to listen on is already in use by another application (like a web server, database, or unrelated service), the Remoting server will fail to bind to that port. When the client tries to connect, there’s no service listening on the port, so the connection is refused. Tools likenetstat -anocan help identify port conflicts quickly.Mismatched Remoting Channel Configurations
Client and server must use fully compatible channel configurations to establish a connection. Common mismatches include:- Server uses an HTTP channel but the client is configured for TCP
- Conflicting serialization formats (binary vs. SOAP)
- Server binds to
localhostbut the client tries to connect via a public IP
These inconsistencies prevent the initial handshake from succeeding, resulting in a connection refusal.
Server Host Process Has Crashed
Even if the Remoting server was running initially, if the host process (like a Windows Service or console app) crashes unexpectedly, subsequent client connection attempts will fail with this error—there’s no longer a service listening on the target port to accept the connection.
内容的提问来源于stack exchange,提问作者JackWinch

