Itext issue Loading Assembly file

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..
LVL 17
ITguy565Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
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.
ITguy565Author Commented:
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

oBdACommented:
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?
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

ITguy565Author Commented:
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
ITguy565Author Commented:
I agree with you however, that should not have been an issue if it worked while local to the folder... Strange..
ITguy565Author Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.