Avatar of ITguy565
ITguy565
Flag for United States of America asked on

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..
PowershellAssemblyScripting Languages

Avatar of undefined
Last Comment
ITguy565

8/22/2022 - Mon
oBdA

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.
ITguy565

ASKER
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

oBdA

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?
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ITguy565

ASKER
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
ITguy565

ASKER
I agree with you however, that should not have been an issue if it worked while local to the folder... Strange..
ASKER CERTIFIED SOLUTION
ITguy565

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question