Can't find `DataProtectionScope` and `ProtectedData` classes in System.Security.Cryptography

As @Coral Doe mentioned in a comment under @Dave Lucre:

"Had a similar problem and this worked. using System.Security.Cryptography; didn't [show] me [ProtectedData] and ProtectedMemory until I had referenced the System.Security.dll for the specific framework."

This fixed the issue for me. Specifically, I performed these steps:

  1. Open the project in Visual Studio.
  2. Right-click the project's name in Solution Explorer then choose Properties.
  3. Click the References tab on the left.
  4. Click the Add button.
  5. Click the .NET tab.
  6. Select System.Security and click OK to add the reference.

Hope this helps.


I have referenced the System.Security.dll here: C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Security.dll

Added using System.Security.Cryptography; and I can see both DataProtectionScope and ProtectedData.

I'm targeting the .net 4.0 full framework (not client profile).

What framework are you targeting?


I had to add this NuGet package in addition to System.Security.Cryptography.

It is https://www.nuget.org/packages/System.Security.Cryptography.ProtectedData/.

After that, System.Security.Cryptography became "used".