在 PowerShell 中加载 WinSCP - 无法加载文件或程序集 - 此程序集由比当前加载的运行时更新的运行时构建
Loading WinSCP in PowerShell - Could not load file or assembly - This assembly is built by a runtime newer than the currently loaded runtime
错误信息:
Add-Type : Could not load file or assembly 'file:///D:\WinSCP-5.15.2-Automation\WinSCPnet.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. I placed WinSCP.dll same folder together with WinSCP.exe**
我运行 PowerShell v2.0.
错误信息中存在问题
导致问题的脚本行如下所示:
#Load WinSCP .NET assembly
Add-Type -Path "C:\users\Desktop\WinSCPnet.dll"
这个 post 几乎与这个 link PowerShell runtime exception - "could not load file or assembly" 和 我尝试了 post 在 link 无法解决。有什么我遗漏的吗?
您可能使用的是旧版本的 .NET Framework。
WinSCP .NET assembly target .NET Framework 4.0.
的最新版本
WinSCP 5.13.9 是在 .NET 2 中运行的最后一个版本。
不过您应该使用最新版本的 WinSCP。毕竟是安全软件。如果无法安装 .NET Framework 4,可以使用 WinSCP scripting instead of .NET assembly. WinSCP itself does not have any dependency on .NET Framework (or anything else). And runs on all versions of Windows since Windows XP.
错误信息:
Add-Type : Could not load file or assembly 'file:///D:\WinSCP-5.15.2-Automation\WinSCPnet.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. I placed WinSCP.dll same folder together with WinSCP.exe**
我运行 PowerShell v2.0.
错误信息中存在问题
导致问题的脚本行如下所示:
#Load WinSCP .NET assembly
Add-Type -Path "C:\users\Desktop\WinSCPnet.dll"
这个 post 几乎与这个 link PowerShell runtime exception - "could not load file or assembly" 和 我尝试了 post 在 link 无法解决。有什么我遗漏的吗?
您可能使用的是旧版本的 .NET Framework。
WinSCP .NET assembly target .NET Framework 4.0.
的最新版本WinSCP 5.13.9 是在 .NET 2 中运行的最后一个版本。
不过您应该使用最新版本的 WinSCP。毕竟是安全软件。如果无法安装 .NET Framework 4,可以使用 WinSCP scripting instead of .NET assembly. WinSCP itself does not have any dependency on .NET Framework (or anything else). And runs on all versions of Windows since Windows XP.