部署 IronPDF NuGet 套件:修復

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。 要正確支援現代 TLS 協議,需要Visual Studio 2015 或更高版本

在 Visual Studio 中,轉到:

  • 工具 > 擴充功能與更新 > 更新 > Visual Studio Gallery
  • 將 NuGet 套件管理器更新至最新版本。

3.在 .NET 中啟用強加密
如果以上步驟無法解決問題,您可能需要在 .NET 中啟用強加密。 這可以透過修改註冊表來實現。

1. 建立一個包含以下內容的`.reg`檔案:

    ```txt
    [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,685,821 | 版本: 2025.12 剛發表