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?

Thank you!

Re: CryptographicException from System.Security.Cryptography.Protected by Jeroen

Jeroen
Tue Apr 22 19:17:46 CDT 2008

ondrej421 wrote:
> 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?
>
> Thank you!

.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.
http://symbolsprose.blogspot.com