自包含的 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 (将#修改为@)