none
X509Certificate2 bug? RRS feed

  • Question

  • Hi,
    I execute a very easy code in Program.cs of Windows forms application (in Program.Main() method):

    X509Certificate2 caCert = new X509Certificate2();
    However, this code results in exception "Object reference not set to an instance of an object."
    What is possible cause of such strange behavior? Constructor doesn't get any parameters, so as I understand it should work in any case; however, null reference exception occures.
    Saturday, October 17, 2009 11:29 AM

Answers

  • Are you certain this is the line that throws the exception? What is the stack trace of the NullReferenceException?
    • Marked as answer by VASoftOnline Sunday, October 18, 2009 7:03 AM
    Saturday, October 17, 2009 12:59 PM

All replies

  • Are you certain this is the line that throws the exception? What is the stack trace of the NullReferenceException?
    • Marked as answer by VASoftOnline Sunday, October 18, 2009 7:03 AM
    Saturday, October 17, 2009 12:59 PM
  • Possibly you right. I solved the problem by just moving this simple code to Form_Load event handler from Program.Main() method. I still don't undertand what is cause of NullReferenceException, however, now software works OK and it is not critical to init CA certificate in Form_Load instead of Program.Main()
    Sunday, October 18, 2009 7:06 AM