Reputation:
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?
Upvotes: 18
Views: 19203
Reputation: 134
I'm sorry, I know that this is a quite old post, but I'm having this issue now and the only workaround that I've found is:
System.Security.Cryptography.DataProtectionScope scope = System.Security.Cryptography.DataProtectionScope.LocalMachine;
instead of DataProtectionScope scope = DataProtectionScope.LocalMachine;
Upvotes: 0
Reputation: 9
Remove references System.Security.Cryptography
and add it again.
It works in my case.
Upvotes: 0
Reputation: 3053
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".
Upvotes: 8
Reputation: 761
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:
Hope this helps.
Upvotes: 76
Reputation: 39200
This might be a slap in your face because you've probably tried that (and you haven't, you might deserve one). What happens if you reinstall the whole IDE? And I meant really the whole thing. Remove the framwork, the VS, remove the files, go paranoid and clean up the trash can, switch to a different installation directory etc. Does the problem still remains?
I know it doesn't explain why it happened but at this stage I'm guessing you're mostly interested in how to kill the problem.
If you have access to a spare computer - why don't you install VS on that machine and see if you can reproduce the error. If not, then there's something fishy with your primary machine and you'll probably never know what happened.
I'm stressing here that it's only a list of general suggestions that every programmer should rely on when nothing sane nor logical seems to work. And yes, I do hate computers. I love programming but I hate computers. They are like small, evil people with keyboards...
Upvotes: -9
Reputation: 16177
As @Dave Lucre asked, what framework is your application targeting? Visual Studio creates all new applications to use the Client Profile by default (which is asinine in my opinion), and it causes all sorts of trouble if you don't specifically change it back. Give that a look, then see where we go from there.
Upvotes: 1
Reputation: 1165
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?
Upvotes: 9