KateMak
KateMak

Reputation: 1649

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

Upvotes: 11

Views: 19809

Answers (1)

Scott Chamberlain
Scott Chamberlain

Reputation: 127563

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.

Upvotes: 10

Related Questions