System.Security.Cryptography not found

11,319

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.

Share:
11,319
KateMak
Author by

KateMak

Updated on June 15, 2022

Comments

  • KateMak
    KateMak almost 2 years

    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

  • KateMak
    KateMak almost 8 years
    When I search System.Security.Cryptography in Nuget, I can only find System.Security.Cryptography.Hashing.Algorithms.Analyzers
  • Scott Chamberlain
    Scott Chamberlain almost 8 years
    @KateMak you likely don't have "Include Prerelease" checked. (unchecked, checked)
  • KateMak
    KateMak almost 8 years
    Apparently I did not have the right release version which is why it was not working. Thank you for your input!!
  • Ermir Beqiraj
    Ermir Beqiraj over 4 years
    Besides what the solution suggests, I had to remove the binding redirects from .netframework project