Problems loading iTextSharp in PowerShell

2

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.

powershell
itextsharp
asked on Stack Overflow Nov 17, 2015 by Paul • edited Nov 17, 2015 by Bruno Lowagie

2 Answers

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

answered on Stack Overflow Nov 17, 2015 by Χpẘ • edited May 23, 2017 by Community
0

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

answered on Stack Overflow Feb 3, 2018 by user9308240

User contributions licensed under CC BY-SA 3.0