【问题标题】:System.Security.Cryptography.Algorithms dll in .net 4.8.net 4.8 中的 System.Security.Cryptography.Algorithms dll
【发布时间】:2022-01-05 13:56:08
【问题描述】:

我在 Visual Studio 2015 中有一个控制台应用程序。(.Net FrameWork 4.8)
我通过 NuGet 安装向这个应用程序添加了 3 个 dll,如下所示:

System.Security.Cryptography.Algorithms 系统安全密码学编码 System.Security.Cryptography.Primitives

但我在这行 c# 中有错误:

using System.Security.Cryptography.Algorithms;

类型或命名空间名称“算法”不存在于 命名空间“System.Security.Cryptography”(您是否缺少程序集 参考?)

问题是什么,我该如何解决?

【问题讨论】:

  • System.Security.Cryptography.Algorithms程序集(DLL)的名称,它不是实际的命名空间 - 所有公共算法实现都有直接命名空间 System.Security.Cryptography(即。 System.Security.Cryptography.SHA256)
  • 由于这个错误,我添加了这些 dll:The type or namespace name 'AesGcm' could not be found (are you missing a using directive or an assembly reference?)
  • 如果您删除 using System.Security.Cryptography.Algorithms; 并尝试在您的代码中引用 AesGcm 类型,现在可以吗?
  • 还是有这个错误:The type or namespace name 'AesGcm' could not be found (are you missing a using directive or an assembly reference?) > 我只加了using System.Security.Cryptography;
  • 看这张图片:i.imgur.com/YyTlkVw.png

标签: c# cryptography .net-4.8


【解决方案1】:

这里需要注意两点:

  • 您正在寻找的AesGcm 实现可用于 .NET Framework 4.8,因此无法解析所需的类型名称。对于跨平台实现,您似乎需要升级到 .NET 5.0
  • System.Security.Cryptography.Algorithms 不是命名空间——它只是程序集的名称(磁盘上的 DLL 文件),其中包含许多加密算法实现。相应 DLL 中包含的所有公共类型都命名为 System.Security.Cryptography,因此 AesGcm 的限定类型名称将是:
    • System.Security.Cryptography.AesGcm

【讨论】:

    猜你喜欢
    • 2021-05-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-22
    相关资源
    最近更新 更多