Deploying IronPDF NuGet Packages: Fixes

This article was translated from English: Does it need improvement?
Translated
View the article in English

尝试部署 NuGet 包时,您可能会看到以下一个或多个错误信息:

Failed to deploy NuGet package '_IronPdf.Native.Chrome.Windows(version)'
System.Net.WebException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send.
System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

可能原因

这些错误的最常见原因与过时的 TLS 协议有关。 截至2020年6月15日,NuGet 已取消对 TLS 1.0 和 1.1 的支持,并强制执行 TLS 1.2。如果您的系统上未启用 TLS 1.2,则 NuGet 命令可能会失败。

如果未启用 TLS 1.2,则从 HTTP 切换到 HTTPS 不会解决问题,因为 NuGet 现在需要安全连接。

解决方案

  1. 安装 Visual C++ 运行库: 确保您的系统上安装了Visual Studio 的 Visual C++ 可再发行组件。 缺少运行库可能会导致某些包的问题,包括 IronPDF。

  2. 更新 Visual Studio: 确保您使用的是最近的、最新版本的 Visual Studio。 Visual Studio 2015 或更高版本需要正确支持现代 TLS 协议。

    • 在 Visual Studio 中,前往:
      • 工具 > 扩展和更新 > 更新 > Visual Studio Gallery
      • 将 NuGet 包管理器更新到最新版本。
  3. 在 .NET 中启用强加密: 如果上述步骤未解决问题,您可能需要在 .NET 中启用强加密。 这可以通过修改注册表来完成。

    1. 创建一个包含以下内容的.reg文件:

      [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319]
      "SchUseStrongCrypto"=dword:00000001
      
      [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319]
      "SchUseStrongCrypto"=dword:00000001
      • 上述注册表项启用了 32 位和 64 位版本的 .NET 中的强加密。
    2. 运行.reg文件以更新注册表设置。 这在 .NET 中启用强加密,允许 TLS 1.2 连接。

无需重启。 应用这些更改后,请尝试再次运行您的 NuGet 命令。

有关更多详细信息,请参考此 Stack Overflow 帖子:NuGet 失败:基础连接已关闭:发生了意外错误。

如果您需要进一步的帮助,请通过提交 工程请求联系我们。

Curtis Chau
技术作家

Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。

除了开发之外,Curtis 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。

准备开始了吗?
Nuget 下载 16,154,058 | 版本: 2025.11 刚刚发布