这似乎是 PowerShell 和 Visual Studio 中的常见问题,但案例和解决方案似乎差异很大。虽然看到了几个类似的问题,但我还没有找到适合我的问题的有效解决方案。
错误消息中存在问题
Could not load file or assembly 'file:///C:\users\jenstmar\Desktop\WinSCP.dll' o r one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
文件位置无效,因为 .dll 应该位于与 WinSCP 相同的文件夹中安装。此位置已更改,以检查是否有任何权利或缺乏权利限制我使用它。
导致问题的脚本行如下所示:
# Load WinSCP .NET assembly
[Reflection.Assembly]::LoadFrom("C:\users\jenstmar\Desktop\WinSCP.dll") | Out-Null
此错误出现在 PowerShell ISE 中和 PS ISE(x86)。我以本地管理员身份在 Windows Enterprise 64 位环境中运行 PowerShell V3.0。我该如何解决这个问题?
最佳答案
该文件可能因其来源(存储在 NTFS streams 中)而被阻止加载。检查属性并查看小解锁按钮是否亮起。一旦你解锁它也许它会加载...
关于exception - PowerShell 运行时异常 - "could not load file or assembly",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13799260/