2016-06-09 109 views
5

我想添加一个对System.Security.Cryptography.X509Certificates的引用,但是我得到:“命名空间'System.Security'中不存在类型或名称空间'加密术'System.Security.Cryptography not found

我曾尝试加入System.Security来引用,我曾尝试加入System.Security.dll,我曾尝试加入mscorlib.dll中,我试图找出如何添加Windows.Security.Cryptography。

无因此我不能使用我需要的X509Certificate2类。

有没有人遇到过这种令人难以置信的令人沮丧的情况?

UPDATE:

望着这个问题,RandomNumberGenerator in ASP.NET5 我无法找到我所寻找的NuGet。在nuget中,我只能看到System.Security.Cryptography.Hashing.Algorithms.Analyzers。我需要System.Security.Cryptography.X509证书

+0

这是不一样的....我找的库不能在Nuget包中找到。 – KateMak

+0

因为它没有指向同一个包中的重复我重新打开问题,并提供了一个链接到NuGet包你需要 –

+2

你正在使用哪个版本的.NET? – ChrisF

回答

5

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

.NET Core(这是新的ASP.NET使用的)是基于组件的体系结构,您需要导入所需功能的包。当您在Visual Studio中搜索时,您可能没有选中“包括预发布”选项,以便筛选出.NET Core的库。

+0

当我在Nuget中搜索System.Security.Cryptography时,我只能找到System.Security.Cryptography.Hashing.Algorithms.Analyzers – KateMak

+1

@KateMak,您可能没有选择“包括预发布”。 ([unchecked](http://i.stack.imgur.com/KqFTI.png),[checked](http://i.stack.imgur.com/2zcq5.png)) –

+0

谢谢我能够找到并安装它,但仍然没有运气... – KateMak