部署 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 画廊
- 将 NuGet 包管理器更新至最新版本。
在 .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
运行
.reg
文件以更新注册表设置。 这使.NET能够使用强加密技术,支持TLS 1.2连接。无需重新启动。 在应用这些更改后,再次尝试运行您的 NuGet 命令。
有关更多详细信息,请参阅此 Stack Overflow 帖子:NuGet fails:基础连接已关闭:发生意外错误。
如需更多帮助,请通过提交工程请求与我们联系。