Problems loading iTextSharp in PowerShell

那年仲夏 提交于 2019-12-07 21:18:58

问题


I am having problem loading the iTextSharp.dll in PowerShell. 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.


回答1:


Looks like this on StackOverflow will probably solve your problem. Apparently you need to add the option <loadFromRemoteSources enabled="true" /> to the .EXEs config file to load an assembly from a network share.

I found this by searching for the HRESULT 0x80131515




回答2:


I have found that the DLL works with PowerShell ISE (x86), but not the 64-bit version of PowerShell ISE.



来源:https://stackoverflow.com/questions/33755936/problems-loading-itextsharp-in-powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!