微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

自包含的 win-x64 可执行文件 AggregateException:主动拒绝连接

如何解决自包含的 win-x64 可执行文件 AggregateException:主动拒绝连接

我正在尝试为 Windows 发布一个独立的可执行文件。当我尝试通过特权 powershell(或 cmd)窗口运行可执行文件时,出现以下错误

Unhandled exception. System.AggregateException: One or more errors occurred. (No connection Could be made because the target machine actively refused it.)
 ---> System.Net.Http.HttpRequestException: No connection Could be made because the target machine actively refused it.
 ---> System.Net.sockets.socketException (10061): No connection Could be made because the target machine actively refused it.
   at System.Net.Http.ConnectHelper.ConnectAsync(String host,Int32 port,CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.ConnectHelper.ConnectAsync(String host,CancellationToken cancellationToken)
   at System.Net.Http.httpconnectionPool.ConnectAsync(HttpRequestMessage request,Boolean allowHttp2,CancellationToken cancellationToken)
   at System.Net.Http.httpconnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request,CancellationToken cancellationToken)
   at System.Net.Http.httpconnectionPool.GethttpconnectionAsync(HttpRequestMessage request,CancellationToken cancellationToken)
   at System.Net.Http.httpconnectionPool.SendWithRetryAsync(HttpRequestMessage request,Boolean doRequestAuth,CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask,HttpRequestMessage request,CancellationTokenSource cts,Boolean disposeCts)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout,CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at myProgram.Client.postClaim(Claim Claim,Byte[]& var1,Byte[]& var2,Byte[]& var3)
   at myProgram.Program.Main(String[] args)

如果相关的话,在那条线上,我将连接到另一台机器上的 tomcat 托管服务器。

奇怪的是,当我发布非独立应用程序时,我没有收到错误消息。应用程序成功运行直至完成。当我在 Visual Studio 中以调试模式运行程序时,我也没有收到错误消息。此外,我为 linux-x64 构建了一个独立的可执行文件,并且能够在 linux 机器上成功运行。

我已尝试禁用 Windows Defender 防火墙和类似程序。但是,由于程序在其他情况下运行良好,我认为这不是防火墙问题。

独立的可执行文件有问题吗?在 Windows 上运行独立的可执行文件之前,我是否遗漏了什么?我不知道如何解决这个问题。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。