从网络 UNC 共享错误 0x80131515 添加类型加载程序集 [英] Add-Type load assembly from network UNC share error 0x80131515
本文介绍了从网络 UNC 共享错误 0x80131515 添加类型加载程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当您想从网络添加程序集时 UNC 共享使用命令:
When you want to add an assembly from a network UNC share using the command:
$scriptPath = Split-Path ($MyInvocation.MyCommand.Path)
Add-Type -path "$scriptPath\selenium-dotnet\net40\WebDriver.dll"
您可能会遇到这样的错误:
you might face such an error:
Add-Type: Could not load file or assembly 'file:///Z:\A-Backup\Users\Administr
ator\Desktop\MAXIMO Automatic\selenium-dotnet\net40\WebDriver.dll' or one of it
s dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515
)
At Z:\A-Backup\Users\Administrator\Desktop\MAXIMO Automatic\MAXIMO Automatic.ps
1:14 char:1
+ Add-Type -path "$scriptPath\selenium-dotnet\net40\WebDriver.dll"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-Type], FileLoadException
+ FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell
.Commands.AddTypeCommand
我该如何解决这个问题?
How can I fix this problem?
推荐答案
关键是允许从网络路径加载程序集用于 PowerShell 可执行文件.可以通过创建两个文件来完成
The key is to allow for loading an assembly from a network path for a PowerShell executable. It can be done by creating the two files
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe.config C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe.config
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe.config C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe.config
并粘贴此代码:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<loadFromRemoteSources enabled="true"/>
</runtime>
</configuration>
这篇关于从网络 UNC 共享错误 0x80131515 添加类型加载程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文