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++ Redistributable。 缺少運行時可能會導致某些套件(包括 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 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。

除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。

準備好開始了嗎?
Nuget 下載 16,154,058 | 版本: 2025.11 剛剛發布