Itext issue Loading Assembly file

ITguy565
ITguy565 used Ask the Experts™
on
Experts,

What would cause the following when running the this command :


Add-Type -Path 'C:\Test-CitrixRebootScript\UtilityFunctions\itext2\itextsharp.dll'

Open in new window


PS C:\Test-CitrixRebootScript\UtilityFunctions\itext2> Add-Type -Path 'C:\Test-CitrixRebootScript\UtilityFunctions\itext
2\itextsharp.dll'
Add-Type : Could not load file or assembly 'file:///C:\Test-CitrixRebootScript\UtilityFunctions\itext2\itextsharp.dll'
or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
At line:1 char:1
+ Add-Type -Path 'C:\Test-CitrixRebootScript\UtilityFunctions\itext2\it ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Add-Type], FileLoadException
    + FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.AddTypeCommand

I have attempted the following already :

Downloaded the most recent version of itext
Downloaded and unblocked folder and files within..
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2018
Distinguished Expert 2018

Commented:
Which OS? Can't reproduce on W2k12R2, W2k16, Win10.
It could be that the dll requires .NET 2.0 (can't find a list of requirements), which is not installed by default.
Not sure why, but I had to set-location to my itext directory before It would work. I couldn't call it by full path.

Importing using this :
*Worked*
Add-Type -Path '.\itextsharp.dll'

Open in new window


*Didn't work**
Add-Type -Path 'C:\Test-CitrixRebootScript\UtilityFunctions\itext2\itextsharp.dll'

Open in new window

Most Valuable Expert 2018
Distinguished Expert 2018

Commented:
Can't reproduce that, either. Can load from pretty much any folder, including the HKLM drive.
Did you first try it from a file system drive or from another provider?
Can you use the full path when you're in the dll's folder?
Are there other dlls in the folder where you were during your first attempt?
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

oBdA no, there are only two files in that folder, the XML and the DLL associated with iText.

PS C:\Test-CitrixRebootScript\UtilityFunctions\itext2>
Unblock-File -Path .\itextsharp.dll

Open in new window


PS C:\Test-CitrixRebootScript\UtilityFunctions\itext2>
Add-Type -Path 'C:\Test-CitrixRebootScript\UtilityFunctions\itext
2\itextsharp.dll'

Open in new window

Add-Type : Could not load file or assembly 'file:///C:\Test-CitrixRebootScript\UtilityFunctions\itext2\itextsharp.dll'
or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
At line:1 char:1
+ Add-Type -Path 'C:\Test-CitrixRebootScript\UtilityFunctions\itext2\it ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Add-Type], FileLoadException
    + FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.AddTypeCommand
I agree with you however, that should not have been an issue if it worked while local to the folder... Strange..
Found my own solution, but now I have more questions than answers. As it shouldn't have been a problem to begin with..


Not sure why, but I had to set-location to my itext directory before It would work. I couldn't call it by full path.

Importing using this :
*Worked*
Add-Type -Path '.\itextsharp.dll'

Open in new window


*Didn't work**
Add-Type -Path 'C:\Test-CitrixRebootScript\UtilityFunctions\itext2\itextsharp.dll'

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial