.NET Framework Developer Center > .NET Framework Forums > Common Language Runtime > DPAPI C# problem - Provider DLL could not be found exception

Unanswered DPAPI C# problem - Provider DLL could not be found exception

  • Friday, December 29, 2006 5:33 PM
     
     
    I'm trying to use the DPAPI C# code found in this article.
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT08.asp

    I can call Encrypt just find and it returns the correct encrypted data.  But when I try and call Decrypt it throws the exception b/c of these lines of code:

    retVal = CryptUnprotectData(ref cipherBlob, null, ref
                    entropyBlob,
                   IntPtr.Zero, ref prompt, dwFlags,
                   ref plainTextBlob);
    if(false == retVal) {
            throw new Exception("Decryption failed. " +
            GetErrorMessage(Marshal.GetLastWin32Error()));
    }

    Basically CryptUnprotectedData is returning false.  Any ideas?

All Replies