window 调用 WCF 的 C# 控制台应用程序的调度程序失败

window Scheduler of C# Console Application calling WCF fails

我有一个从远程 WCF 服务获取数据的 C# 控制台应用程序。该应用程序 运行 在 Visual studio 中很好,如果我只需双击 C# Release Bin 文件夹中的 application.exe 文件。两种情况 运行 都很好。

但是,当我尝试通过 Windows 调度程序安排 运行 时,出现此错误

The remote name could not be resolved: at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) at System.Net.HttpWebRequest.GetRequestStream() at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream()

知道为什么双击控制台 application.exe 工作正常,但 运行 使用 windows 调度程序无法正常工作。当我通过 Windows Scheduler 运行 时,错误提示无法解析服务地址。

完整堆栈跟踪:

System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at https://abc.defg.com:444/somedata.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. ---> System.Net.WebException: The remote name could not be resolved: 'abc.defg.com' at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) at System.Net.HttpWebRequest.GetRequestStream() at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream() --- End of inner exception stack trace ---

Server stack trace: at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream() at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.SendRequest(Message message, TimeSpan timeout) at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

这是内网防火墙问题。