The code example "How to: Envelope a Message for One Recipient" throw exception when the certificate "Recipient1" is created by makecert RRS feed

  • Question

  • I compile and execute the example code in with title "How to: Envelope a Message for One Recipient".

    I got exception with message "Key error" when the process execute the statement:
    Can any one tell me what is wrong and how to fix it?

    My Detail steps:
    1. Use following statement to create appropriate public/private key pairs.

    Makecert -n "CN=Recipient1" -ss My

    2. export the public key certificate, and then import it into the AddressBook certificate store by following the procedure in How to: Export and Import a Public Key Certificate.

    3. compile the code in and execute.

    By the way, my OS is Vista and my tool is C# 2008 express.

    In fact, if I replace the Certificate "Recipient1" created by makeceert with the valid certificate of my bank accocunt, every thing is OK.

    Wednesday, July 8, 2009 2:49 AM


  • The solution is:
    use command 
    makecert -r -pe -sky Exchange -n "CN=Recipient1" -ss MY
    in stead of 
    Makecert -n "CN=Recipient1" -ss My
    • Marked as answer by hjyanghj Wednesday, July 29, 2009 3:23 PM
    Wednesday, July 29, 2009 3:23 PM