【问题标题】:Can't add referenced assembly powershell core无法添加引用的程序集 powershell 核心
【发布时间】:2019-04-16 02:05:08
【问题描述】:

我一般都喜欢 powershell,但引用程序集总是很困难。

使用 powershell 6.2。我需要创建一个存在于 System.Security.Cryptography.Csp.dll 中的对象。该 dll 位于 C:\Program Files\PowerShell\6\ref 中。

这是使用垃圾参数创建的有问题的对象:
New-Object PasswordDeriveBytes($null, $null, 'SHA1', 2)

以下是我尝试添加对带有错误的加密 dll 的引用:

  • Add-Type -AssemblyName *System.Security.Cryptography.Csp* # 找不到类型
  • Add-Type -AssemblyName System.Security.Cryptography.Csp.dll # 找不到路径'C:\pathToMyScript\System.Security.Cryptography.Csp.dll',因为它不存在
  • Add-Type -Path 'System.Security.Cryptography.Csp.dll' # 与上述相同的错误
  • Add-Type -Path 'C:\Program Files\PowerShell\6\ref\System.Security.Cryptography.Csp.dll' # 找不到类型 [PasswordDeriveBytes]:验证是否加载了包含此类型的程序集(Add-Type 没有错误)

如何简单地添加对使用 powershell 安装的程序集的引用?再多看其他示例也无济于事,似乎它们通常是上述变体之一。

【问题讨论】:

  • [PasswordDeriveBytes] -> [System.Security.Cryptography.PasswordDeriveBytes]

标签: powershell


【解决方案1】:

答案是@PetSerAl 的评论,只是完全限定类型。无需引用程序集。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-23
    • 1970-01-01
    • 1970-01-01
    • 2021-02-12
    • 2015-08-02
    • 2021-09-21
    相关资源
    最近更新 更多