部署 IronPDF NuGet 套件:修復
嘗試部署 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 失敗:底層連線已關閉:發生意外錯誤。
如果您需要進一步的協助,請提交工程請求與我們聯絡。






