.net - 如何在 PowerShell 2.0 中加载 WinSCPnet.dll 程序集?(此程序集由比当前加载的运行时更新的运行时构建)
问题描述
我正在尝试WinSCPnet.dll
在 PowerShell 中使用以下代码加载文件,但出现以下错误。
Set-Location "D:\WinSCP-5.17.10-Automation"
Add-Type -Path "WinSCPnet.dll"
Add-Type : 无法加载文件或程序集 'file:///D:\WinSCP-5.17.10-Automatio n\WinSCPnet.dll' 或其依赖项之一。此程序集由比当前加载的运行时更新的运行时构建,无法加载。
在 line:2 char:9
+ Add-Type <<<< -Path "WinSCPnet.dll"
+ CategoryInfo : NotSpecified: (:) [Add-Type], BadImageFormatExce ption
+ FullyQualifiedErrorId : System.BadImageFormatException,Microsoft.PowerShell。 Commands.AddTypeCommand
有没有其他方法可以在 PowerShell 2.0 中添加此程序集,如果不支持,是否有任何WinSCPnet.dll
可用的支持 PowerShell 2.0?
解决方案
我认为问题不在于 PowerShell 2 本身。这是关于 PowerShell 加载的 .NET 框架版本。当前版本的 WinSCP .NET 程序集面向 .NET 4.0。您可能已经安装了该版本。您只需要配置 PowerShell 即可使用它。
有涵盖此内容的 WinSCP 文章:
https ://winscp.net/eng/docs/message_net_runtime_newer_than_currently_loaded
按照那里的建议,尝试:
set COMPLUS_version=v4.0.30319
powershell ...
推荐阅读
- javascript - 如何将动态值传递给jquery验证函数
- java - 将用户发送到应用程序。如果 App 不存在发送到 playstore
- json - Oracle 12c PL/JSON 在 5000 个字符处截断字符串
- unit-testing - 带有 test-utils 的 vue.js 测试单元未通过
- ruby-on-rails - 在 Rails 中默认使用 postgres
- r - r中的行随机抽样
- java - 使用扫描仪进行嵌套方法测试
- r - 计数同时满足这两个条件的 ID
- python - 在 For 循环内循环时,在计数器索引 Python 处跳回 For 循环
- android - 如何在活动处于前台时捕获活动中的 FCM 通知?