部署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現在要求安全連接。
解決方案
-
安裝Visual C++執行時庫: 確保您的系統上安裝了Visual Studio 的Visual C++ Redistributable。 缺少運行時可能會導致某些套件出現問題,包括IronPDF。
-
更新Visual Studio: 確保您使用的是一個最近的、最新的Visual Studio版本。 需Visual Studio 2015或更高版本才能正確支持現代的TLS協定。
- 在Visual Studio中,前往:
- 工具 > 延伸與更新 > 更新 > Visual Studio Gallery
- 將NuGet套件管理器更新到最新版本。
- 在Visual Studio中,前往:
-
在.NET中啟用強加密: 如果上述步驟未能解決問題,您可能需要在.NET中啟用強加密。 這可以通過修改登錄檔來完成。
-
建立一個
.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- 上述的登錄檔項允許在.NET的32位和64位版本中使用強加密。
- 執行
.reg文件以更新登錄檔設置。 這會在.NET啟用強加密,允許TLS 1.2連接。
-
不需要重新啟動。 應用這些變更後,嘗試再次運行您的NuGet命令。
詳細資訊,請參閱這篇Stack Overflow貼文:NuGet失敗:基礎連接已關閉:發生意外錯誤。
如果您需要進一步協助,請提交工程請求與我們聯繫。

