X509certificate2.PrivateKey - Problems with Windows Vista RRS feed

  • Question

  • Hi NG,


    i have a problem and do not know howto solve it.

    I am customizing the cardwriter sample (windows cardspace) and i am having problems to sign the SignedXml with the privateKey of the certificate the user selects before

    So, here is some code


    1) The User selects a certificate. This certificate is a parameter for the SerializeAndSign-Method



    Code Block

    public void SerializeAndSign(string filename, X509Certificate2 cert)


    MemoryStream stream = new MemoryStream();

    XmlWriter writer = XmlWriter.Create(stream);






    2) when it comes to get the PrivateKey-Property of the X509certificate2-certificate i get an CryptographicException. The German error is "Der registrierte Schlüsselsatz wurde nicht gefunden" so it must be sth. like "The registered key pair is not defined"...


    Code Block


    //set signing key of SignedXML

    signed.SigningKey = cert.PrivateKey;



    The same code runs as expected under Windows XP...looking in the MSDN Library i found that the PrivateKey-Property is "specific to .NET Framework 3.0" but does not run under WIndows Vista?

    Maybe someone has got an idea...




    Saturday, November 3, 2007 5:00 PM