找不到System.Security.Cryptography

时间:2016-06-09 21:36:24

标签: c# asp.net .net asp.net-mvc cryptography

我正在尝试添加对System.Security.Cryptography.X509Certificates的引用,但我得到:"类型或命名空间'密码学'命名空间中不存在System.Security'。

我已经尝试将System.Security添加到引用,我尝试添加System.Security.dll,我尝试添加mscorlib.dll,我试图找到如何添加Windows.Security.Cryptography。

没有运气,因此我不能使用我需要的X509Certificate2类。

有没有人遇到这种不可思议的令人沮丧的情况?

更新:

看看这个问题,RandomNumberGenerator in ASP.NET5 我在Nuget找不到我要找的东西。在nuget中,我只看到System.Security.Cryptography.Hashing.Algorithms.Analyzers。我需要System.Security.Cryptography.X509Certificates

1 个答案:

答案 0 :(得分:8)

您需要将System.Security.Cryptography.X509Certificates NuGet项目的引用添加到ASP.NET项目中。

.NET Core(新ASP.NET使用的)是基于组件的体系结构,您需要导入所需功能的包。在Visual Studio中搜索时,您可能没有选中“Include Prerelease”选项,因此.NET Core的库已被过滤掉。