Psst! Did you know DevelopmentNow is a mobile web site design agency?

Contact us for help mobilizing your site, or to sign up for our beta Mobile Web SDK!
all groups > dotnet framework > april 2008 >

dotnet framework : CryptographicException from System.Security.Cryptography.Protected


ondrej421
4/22/2008 4:58:01 PM
Hi there,

On some computers running Windows XP, the ProtectData() method sometimes
throws the following CryptographicException:

Type: System.Security.Cryptography.CryptographicException
Message: The system cannot find the file specified.

Source: System.Security
Stack Trace:
at System.Security.Cryptography.ProtectedData.Protect(Byte[] userData,
Byte[] optionalEntropy, DataProtectionScope scope)
...

This is how the method is being called:
byte[] encrypted = ProtectedData.Protect(plain, null,
DataProtectionScope.CurrentUser);

I can't find an answer to why this would be happening. Can anyone think of a
possible reason?

Jeroen Mostert
4/23/2008 2:17:46 AM
[quoted text, click to view]

..Protect() is a thin wrapper around the native CryptProtectData() function,
so it's safe to say this has nothing to do with the .NET framework itself.
CryptProtectData() doesn't document a special failure mode.

Assuming the "file not found" is genuine (and not a bogus error value
produced as a result of a bug) try installing Filemon
(http://technet.microsoft.com/en-us/sysinternals/bb896642.aspx) to see if
there are any obvious API calls failing when you use ProtectedData().

--
J.
AddThis Social Bookmark Button