RSACng does not contain a definition for ExportRSAPrivateKey

1.2k Views Asked by At

I have imported System.Security.Cryptography.Cng using NuGet and can instantiate the RSACng class... however, the methods ExportRSAPrivateKey (and ImportRSAPrivateKey) are not there.

I am using version 5.0.0 (latest stable)

According to the documentation these functions should be available.

Any help?

1

There are 1 best solutions below

0
On BEST ANSWER

Those methods were added in .NET Core 3.0. They're available for compile targets .NET Core 3.0, .NET Core 3.1, .NET 5, any versions that succeed .NET 5, and .NET Standard 2.1.

.NET Standard 2.0 is a common target for libraries because it provides a common targeting point for both .NET Framework and .NET Core / .NET. Since the methods aren't available in .NET Framework they aren't in .NET Standard 2.0.

Double check that your library is set to compile against an appropriate target.