如何在PowerShell中修复DLL LoaderException

时间:2019-04-04 21:18:51

标签: powershell dll dllimport

我正尝试加载itext7的.dll,但是如果我使用它

Add-Type -Path "D:\Eigene\Packages\itext7.7.1.5\lib\net40\itext.kernel.dll"

我得到以下异常(翻译自德语):

Add-Type : Add-Type : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
In Zeile:2 Zeichen:1
+ Add-Type -Path "D:\Eigene\Packages\itext7.7.1.5\lib\net40\itext.kerne ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Add-Type], ReflectionTypeLoadException
    + FullyQualifiedErrorId : System.Reflection.ReflectionTypeLoadException,Microsoft.PowerShell.Commands.AddTypeCommand

当我使用时:

try   { Add-Type -Path "D:\Eigene\Packages\itext7.7.1.5\lib\net40\itext.kernel.dll" }
catch { $_.Exception.LoaderExceptions }

它说(也翻译成德语):

  

文件或程序集“ BouncyCastle.Crypto,版本= 1.8.1.0,   文化=中性,PublicKeyToken = 0e99375e54769942”或以下项的依赖项   找不到。系统找不到指定的文件。

我该如何解决?

编辑: 我在系统上发现一个BouncyCastle dll,当我安装itext7软件包时也下载了该dll,但如果在加载"D:\Eigene\Packages\Portable.BouncyCastle.1.8.5\lib\net40\BouncyCastle.Crypto.dll"之前先加载itext.kernel.dll,它也将无法正常工作。

0 个答案:

没有答案