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.

Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165
Paul
  • 41
  • 2
  • 3
  • I wonder if that is a 32-bit assembly and you are in x64 PowerShell? Also does it make a difference if you are running as admin. – Matt Nov 17 '15 at 14:02
  • Looks like [this](http://stackoverflow.com/questions/8524423/could-not-load-file-or-assembly-hresult-0x80131515-when-adding-controller-to-m) on StackOverflow will probably solve your problem. – Χpẘ Nov 17 '15 at 21:39

2 Answers2

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

Community
  • 1
  • 1
Χpẘ
  • 3,403
  • 1
  • 13
  • 22
0

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