简体   繁体   English

在 PowerShell 中加载 iTextSharp 时出现问题

[英]Problems loading iTextSharp in PowerShell

I am having problem loading the iTextSharp.dll in PowerShell.我在 PowerShell 中加载 iTextSharp.dll 时遇到问题。 Sometimes it works fine using either:有时使用以下任一方法都可以正常工作:

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

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

However, most times I get the following error:但是,大多数时候我会收到以下错误:

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 

I have tried unblocking the file but I still get the error above.我已尝试解除对文件的阻止,但仍然出现上述错误。

Looks like this on StackOverflow will probably solve your problem.看起来像 StackOverflow 上的这个可能会解决你的问题。 Apparently you need to add the option <loadFromRemoteSources enabled="true" /> to the .EXEs config file to load an assembly from a network share.显然,您需要将选项<loadFromRemoteSources enabled="true" />到 .EXEs 配置文件以从网络共享加载程序集。

I found this by searching for the HRESULT 0x80131515我通过搜索 HRESULT 0x80131515 找到了这个

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM