c# - Problems when P/Invoking CertCreateSelfSignCertificate -
i following this article (in there link .cs file @ bottom of page) generate self-signed x509certificate2 . code in article works want extend it. trying pass optional argument, _in_opt_ pcrypt_algorithm_identifier psignaturealgorithm , certcreateselfsigncertificate . i have created structure it: struct cryptoapiblob { public int32 cbdata; public intptr pbdata; } struct cryptalgorithmidentifier { public string pszobjid; public cryptoapiblob parameters; } the code trying use create is: cryptalgorithmidentifier algorithm = new cryptalgorithmidentifier { pszobjid = "szoid_nist_aes256_cbc", parameters = new cryptoapiblob { cbdata = 0 } }; algorithmpointer = marshal.allochglobal(marshal.sizeof(algorithm)); marshal.structuretoptr(algorithm, algorithmpointer, false); i pass algorithmpointer method. i error when try pass certcreateselfsigncertificate : an unhandled exception of type 'system.runtime.interopservices.comexception' occurred...