C# – Can’t find `DataProtectionScope` and `ProtectedData` classes in System.Security.Cryptography

ccryptographyvisual studio 2010

I've referred the file System.Security.dll as described in this article but according to my IDE, the line using System.Security.Cryptography; can be safely removed as it's not being used.

The same IDE tells me that I've got an error with DataProtectionScope and ProtectedData. Those are supposed to be in that namespace. However, when I dot my way through the packages, I can't see them in there.

Is the article wrong? How can I access the two classes?

Best Answer

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.