1

我正在尝试为 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, Int32 port, 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 上运行自包含的可执行文件之前,我是否遗漏了什么?我不知道如何解决这个问题。

4

0 回答 0