Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Security.Cryptography not found

I am trying to add a reference to System.Security.Cryptography.X509Certificates but I get: "The type or namespace 'Cryptography' does not exist in the namespace 'System.Security'.

I have tried adding System.Security to references, I have tried adding System.Security.dll, I have tried adding mscorlib.dll, I have tried to find how to add Windows.Security.Cryptography.

No luck, therefore I cannot use the X509Certificate2 class, which I need.

Has anyone run into this impossibly frustrating situation?

UPDATE:

Looking at this question, RandomNumberGenerator in ASP.NET5 I cannot find what I am looking for in Nuget. In nuget, I only see System.Security.Cryptography.Hashing.Algorithms.Analyzers. I need System.Security.Cryptography.X509Certificates

like image 213
KateMak Avatar asked Jun 09 '16 21:06

KateMak


1 Answers

You need to add a reference to the System.Security.Cryptography.X509Certificates NuGet project to your ASP.NET project.

.NET Core (which is what the new ASP.NET uses) is a component based architecture, you need to import the packages of the features you want. When you searched in Visual Studio you likely did not have the "Include Prerelease" option checked so the libraries for .NET Core where filtered out.

like image 175
Scott Chamberlain Avatar answered Nov 03 '22 00:11

Scott Chamberlain