在PowerShell中加载iTextSharp时出现问题

时间:2015-11-17 11:35:49

标签: powershell itextsharp

我在PowerShell中加载iTextSharp.dll时遇到问题。有时它使用以下两种方法都可以正常工作:

[System.Reflection.Assembly]::LoadFrom("C:\dll\itextsharp.dll")

Add-Type -Path C:\dll\itextsharp.dll'

但是,大多数情况下我都会收到以下错误:

Exception calling "LoadFrom" with "1" argument(s):
    "Could not load file or assembly 'file:/// C:\dll\itextsharp.dll'
    or one of its dependencies. Operation is not supported.
    (Exception from HRESULT: 0x80131515)"
At line:1 char:1
+ [System.Reflection.Assembly]::LoadFrom("itextsharp.dll")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FileLoadException 

我尝试解锁该文件,但仍然遇到上述错误。

2 个答案:

答案 0 :(得分:1)

看起来StackOverflow上的Queries: Retrieving Results可能会解决您的问题。显然,您需要将选项someOptional添加到.EXE配置文件以从网络共享加载程序集。

我通过搜索HRESULT 0x80131515

找到了这个

答案 1 :(得分:0)

我发现DLL可以与PowerShell ISE(x86)一起使用,但不适用于64位版本的PowerShell ISE。