用remoting实现的windows服务程序,一直运行良好,突然发现不能随系统启动了,手动启动没有问题。在事件查看器中发现提示如下异常:
无法启动服务。System.Runtime.Remoting.RemotingException: 远程处理配置失败,异常为“System.Reflection.TargetInvocationException: 调用的目标发生了异常。 ---> System.Net.Sockets.SocketException: 请求的名称有效,但是找不到请求的类型的数据。
在 System.Net.Dns.GetAddrInfo(String name)
在 System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6)
在 System.Net.Dns.GetHostEntry(String hostNameOrAddress)
在 System.Runtime.Remoting.Channels.CoreChannel.GetMachineName()
在 System.Runtime.Remoting.Channels.CoreChannel.GetMachineIp()
在 System.Runtime.Remoting.Channels.Tcp.TcpServerChannel.SetupMachineName()
在 System.Runtime.Remoting.Channels.Tcp.TcpServerChannel..ctor(IDictionary properties, IServerChannelSinkProvider sinkProvider, IAuthorizeRemotingConnection authorizeCallback)
在 System.Runtime.Remoting.Channels.Tcp.TcpChannel..ctor(IDictionary properties, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider)
防火墙关闭杀毒软件关闭都无效。
网上查了一圈也没有结果,只看到有人说可能是dns解析的问题,想到前两天修改了电脑的hosts文件,然后将hosts文件中增加的代码删除重启电脑后恢复正常