我正在尝试设置一个简单的远程处理Windows服务,并在启动服务时收到以下错误:
System.Net.Sockets Error: 0 : [4180] Exception in the Socket#33711845::DoBind - Only one usage of each socket address (protocol/network address/port) is normally permitted
System.Net.Sockets Verbose: 0 : [4180] ExclusiveTcpListener#4032828::Start()
System.Net.Sockets Verbose: 0 : [4180] Socket#33711845::Bind(0:9998#9998)
System.Net.Sockets Error: 0 : [4180] Exception in the Socket#33711845::DoBind - Only one usage of each socket address (protocol/network address/port) is normally permitted
在Windows服务应用程序中,我在“OnStart”方法中有以下代码 - 注册Channel时出错 - ChannelServices.RegisterChannel(tcpPipe,true);据我所知,没有其他进程使用端口9998 ...
protected override void OnStart(string[] args)
{
int portNumber = int.Parse(ConfigurationManager.AppSettings["endPointTCPPort"]);
TcpChannel tcpPipe = new TcpChannel(portNumber);
ChannelServices.RegisterChannel(tcpPipe, true);
Type serviceType = Type.GetType("TractionGatewayService.TractionGateway");
try
{
RemotingConfiguration.RegisterWellKnownServiceType(serviceType, "updateCustomerDetails", WellKnownObjectMode.SingleCall);
}
catch (RemotingException e)
{
EventLog.WriteEntry("unable to establish listening port because " + e.message;
ChannelServices.UnregisterChannel(tcpPipe);
}
答案 0 :(得分:0)
我发现了问题。我有两个单独的调用TcpChannel来注册端口 - 因此错误。
感谢所有看过这个的人。
...